what is use of forward declaration " Ui::MainWindow *ui; " in qt ?
-
I want to know reason behind use of Ui::MainWindow *ui; in header file
-
I want to know reason behind use of Ui::MainWindow *ui; in header file
@Qt-embedded-developer Explained in documentation: https://doc.qt.io/qt-5/designer-using-a-ui-file.html
-
@Qt-embedded-developer Explained in documentation: https://doc.qt.io/qt-5/designer-using-a-ui-file.html
@jsulm means its use for 2 purpose
1] provides the code for setting up and managing the user interface.
2] the form can then be changed without recompiling the dependent source files -
@jsulm means its use for 2 purpose
1] provides the code for setting up and managing the user interface.
2] the form can then be changed without recompiling the dependent source files@Qt-embedded-developer
It means what it says there:Using a Pointer Member Variable
Alternatively, the Ui::CalculatorForm structure can be made a pointer member of the class
The advantage of this approach is that the user interface object can be forward-declared, which means that we do not have to include the generated ui_calculatorform.h file in the header. The form can then be changed without recompiling the dependent source files.
When you declare
Ui::MainWindow *ui;
(a pointer) in a header file, if the definition ofUi::MainWindow
changes (e.g. widgets added) you do not have to recompile modules which include just the pointer declaration, rather than the class it points to. C++ stuff.