What's the best way to deal with multiple Qt Designer UI forms in one program?



  • Hi I'm using Qt Designer to help create my program. When the program starts I want a wizard to show up to guide through setup steps. Then when done I want to open a main window. The wizard was originally designed in Qt Creator using the Designer then modified with standalone Qt Designer and the main window was designed in standalone Qt Designer. When I created the original project in the new project wizard in Qt Creator I chose the Generate Form option and I developed my wizard form from this main project form. Now if I add the lone UI file for the main screen to the project that was designed in Qt Designer I can no longer build the project. If I go to the new file or project wizard and create a qt designer form class to add to the project I can make the main window show but I can't access it's widget components. So should I start over and add my ui form classes one by one? Is it OK to do it the way I did where I start with the generate form option and create a main program form before I add the second form to the project? Is there a best way to approach this scenario? How do I access the second form's widget components from the main cpp file and can I store all my program logic in one main file or do I need to split it up between all the form classes? Thanks!


  • Qt Champions 2016

    @Crag_Hack said:

    Is it OK to do it the way I did where I start with the generate form option and create a main program form before I add the second form to the project?

    The order in which you add the forms to the project shouldn't matter.

    Is there a best way to approach this scenario?

    You should provide some more information on how you manage your UI. There ain't a best approach, some people build the UI by hand, I personally use the Designer. Some people attach their own widget subclasses to initialize the forms, some don't.

    How do I access the second form's widget components from the main cpp file and can I store all my program logic in one main file or do I need to split it up between all the form classes?

    Depends on your approach to using the form itself. You can store the form and program logic in a QObject subclass (what I usually do), you can have a QWidget or QMainWidget derived to do that, or you can have main() do it. Again, it depends on how you've structured your program.

    Kind regards.



  • Thanks for the help. I managed to figure everything out by trial and error. Also re:

    The order in which you add the forms to the project shouldn't matter.
    

    IIRC when I added the form via the generate form option on the new project wizard the ui became integrated into my project class instead of separate. So I like to do the other way where I add after creating the project.


  • Qt Champions 2016

    @Crag_Hack
    The class that's generated by the creator for the form is just a shorthand for you. You can write manually the same class without it being generated at any point.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.