Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What's the best way to deal with multiple Qt Designer UI forms in one program?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.6k 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.
  • C Offline
    C Offline
    Crag_Hack
    wrote on last edited by A Former User
    #1

    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!

    kshegunovK 1 Reply Last reply
    0
    • C Crag_Hack

      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!

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Crag_Hack
        wrote on last edited by
        #3

        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.

        kshegunovK 1 Reply Last reply
        0
        • C Crag_Hack

          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.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @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.

          Read and abide by the Qt Code of Conduct

          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