Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for a Qt application with multiple UIs in C++

Tags:

c++

qt

The case is as follows:

You have a main window (ui1) that is to contain two other UIs (ui2 and ui3). Neither ui2 nor ui3 care about any other uis. They only have slots to react to, and they might emit signals as well. See drawing below.

+----------------------------+
| +------+        +------+   |
| |      |        |      |   |
| |      |        |      |   |
| |      |        |      |   |
| |   ui2|        |   ui3|   |
| +------+        +------+   |
|                            |
|                        ui1 |
+----------------------------+

ui1 is loaded by AppWindow class and is used like this:

...
int main(int argc, char *argv[])
{
    CustomApp app(argc,argv);

    AppWindow w;
    w.show();

    return app.exec();
}

What is a recommended way of creating the AppWindow class? Any simple example?

Thanks

like image 879
Daniel Avatar asked Jul 01 '10 21:07

Daniel


1 Answers

When creating ui1, drag two basic widgets (i.e. QWidget) into the UI. Then, in designer, you can right click and choose Promote To .... Within that dialog specify the "Promoted class name" and the "Header file" that correspond to ui2 and ui3.

You won't be able to see a live preview using this method, but when the header and class name are specified correctly it will compile and work correctly.

like image 115
Kaleb Pederson Avatar answered Sep 30 '22 23:09

Kaleb Pederson