Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Creator and coding questions.
QtWS25 Last Chance

Creator and coding questions.

Scheduled Pinned Locked Moved Qt Creator and other tools
5 Posts 3 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nevering
    wrote on last edited by
    #1

    I was looking at the "contextsenstivehelp" example that came with QT 4.71 and have some beginner questions.

    In the .ui there is a widget named WateringConfigDialog as the main widget. This seems to be the only place this name is used except for the naming for the .cpp and .h files and the includes of those files. In addition I see this in the main.cpp
    WateringConfigDialog dia;
    return dia.exec();

    My question is why doesn't the wateringconfigdialog.h us the ui.wateringconfigdialog instead of QDialog ?

    I'm looking to base a class of a widget that is within a widget. It has a scrollbar placed via Creator. I'm guessing that by the example here that I'll have to assume that I create my class as here? Or is there a better way to use the ui elements in my code (new cpp and .h) . An example would help.

    Assume all i have is a parent Widget, that contains another widget that I will use for drawing named formwidget, and a scrollarea for formwidget named formscrollwidget.

    thanks for the help

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nevering
      wrote on last edited by
      #2

      Another example is in padnavigator that comes with QT. The .ui file has a treeWidget for the tree view on the main widget. This treeWidget is not used anywhere in the example.

      I'm asking myself if Creator just for show ? Why do layouts and objects in the .ui, if they aren't used in any of the code ?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        Experiment: Just remove the widgets you think are unneeded and find out what breaks:-) That is what the examples are for.

        I do not know the examples on the top of my head, but my guess is that the WaterConfigDialog does show a UI to configure water (or whatever;-) while the QDialog is a generic and mostly empty widget without water configuration UI.

        Note that some of the examples are meant to show e.g. inter widget navigation. In there some widgets have no other use but to show how the widget is used using the keyboard. Read the documentation on the example to find out what it is actually meant to demonstrate.

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          Your question actually is: why WateringConfigDialog Widget(from .ui file) is used like a class name?
          Short answer: that's because WateringConfigDialog is a class.

          My longer answer is: Qt (uic) hides its generated class for WateringConfigDialog (ui created widget) in the namespace Ui:: (and by naming ui_WateringConfigDialog ) that is why in the class WateringConfigDialog (class instantiated in main.cpp and declared in WateringConfigDialog.h) has an instance of Ui::WateringConfigDialog (or ui_WateringConfigDialog ) (or a pointer to an instance)
          The design reason for this decision is most likely the Trolls think that if you gave a name to the widget in .ui file, you may want to use exactly same name for your final class (the class you are using in code to access ui objects).

          More about integrating ui in C++ code can be found "here":http://doc.qt.nokia.com/4.7/designer-using-a-ui-file.html

          Also my personal opinion is that the examples are not the "right" way of starting programming using C++ and Qt. (don't get me wrong the examples are great, just not the way to start)
          I think you must understand the concepts that Qt uses before digging in the examples, so i think you should start with the tutorials or a book (whatever you like more)
          Also "this":http://doc.qt.nokia.com/4.7/qt-basic-concepts.html page can be used for additional explanations for basic concepts that are used by Qt framework.

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Nevering
            wrote on last edited by
            #5

            Does anyone know of any example that make good and appropriate use of the .ui file along with several separate class files.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved