Creator and coding questions.
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
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
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 ?
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.
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.
Does anyone know of any example that make good and appropriate use of the .ui file along with several separate class files.