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. Add second window in same ui file or create new .ui file?
Forum Update on Tuesday, May 27th 2025

Add second window in same ui file or create new .ui file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.5k Views 1 Watching
  • 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.
  • W Offline
    W Offline
    WorldTeacher
    wrote on 20 Sept 2022, 12:42 last edited by WorldTeacher
    #1

    I am creating a UI using the Qt designer and want to make a second window to configure settings. Can I create the UI in the same file as my main UI or do I have to create a new .ui file and load it in the code?

    J 1 Reply Last reply 20 Sept 2022, 12:45
    0
    • W WorldTeacher
      20 Sept 2022, 12:42

      I am creating a UI using the Qt designer and want to make a second window to configure settings. Can I create the UI in the same file as my main UI or do I have to create a new .ui file and load it in the code?

      J Offline
      J Offline
      JonB
      wrote on 20 Sept 2022, 12:45 last edited by
      #2

      @WorldTeacher
      If you want a quite independent, separate widget in Designer you must design it as separate file. And do whatever in code you want for displaying it when. Depending on your usage, you might design in same .ui file if you choose to use a QStackedWidget in Designer.

      W 1 Reply Last reply 20 Sept 2022, 12:52
      1
      • J JonB
        20 Sept 2022, 12:45

        @WorldTeacher
        If you want a quite independent, separate widget in Designer you must design it as separate file. And do whatever in code you want for displaying it when. Depending on your usage, you might design in same .ui file if you choose to use a QStackedWidget in Designer.

        W Offline
        W Offline
        WorldTeacher
        wrote on 20 Sept 2022, 12:52 last edited by
        #3

        @JonB When I created the main UI, I used the "templates/Main Window". I'll create a second file and figure out how to call it. Thanks for the help ^^

        J 1 Reply Last reply 20 Sept 2022, 12:58
        0
        • W WorldTeacher
          20 Sept 2022, 12:52

          @JonB When I created the main UI, I used the "templates/Main Window". I'll create a second file and figure out how to call it. Thanks for the help ^^

          J Offline
          J Offline
          JonB
          wrote on 20 Sept 2022, 12:58 last edited by JonB
          #4

          @WorldTeacher
          Well think about how/when you do want to call it, e.g. maybe it's on a button press from the first window? And think about its widget/window kind, e.g. is it supposed to be a dialog or an independent window? It will help if you decide things before you choose what kind of widget to design and having to change that choice later.

          W 1 Reply Last reply 20 Sept 2022, 13:03
          0
          • J JonB
            20 Sept 2022, 12:58

            @WorldTeacher
            Well think about how/when you do want to call it, e.g. maybe it's on a button press from the first window? And think about its widget/window kind, e.g. is it supposed to be a dialog or an independent window? It will help if you decide things before you choose what kind of widget to design and having to change that choice later.

            W Offline
            W Offline
            WorldTeacher
            wrote on 20 Sept 2022, 13:03 last edited by
            #5

            @JonB When I designed the original "Main" Window, I was planning on using json files to configure settings. But in the process of development some coworkers expressed interest in using the program and they are not realy comfortable with editing "random" files, so I thought I'd be able to add a second window for the settings. I'll do some testing and will probably figure something out.

            J 1 Reply Last reply 20 Sept 2022, 14:23
            0
            • W WorldTeacher
              20 Sept 2022, 13:03

              @JonB When I designed the original "Main" Window, I was planning on using json files to configure settings. But in the process of development some coworkers expressed interest in using the program and they are not realy comfortable with editing "random" files, so I thought I'd be able to add a second window for the settings. I'll do some testing and will probably figure something out.

              J Offline
              J Offline
              JonB
              wrote on 20 Sept 2022, 14:23 last edited by
              #6

              @WorldTeacher
              That in itself is fine. The question is how that editing window is to be shown relative to the main window, whether it should maybe be a modal dialog, etc.

              W 1 Reply Last reply 20 Sept 2022, 16:38
              0
              • J JonB
                20 Sept 2022, 14:23

                @WorldTeacher
                That in itself is fine. The question is how that editing window is to be shown relative to the main window, whether it should maybe be a modal dialog, etc.

                W Offline
                W Offline
                WorldTeacher
                wrote on 20 Sept 2022, 16:38 last edited by
                #7

                @JonB I'll give that some thought and work on something. It'll probably be some dialog window with a "save" button and some Labels and lineEdit Fields.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 20 Sept 2022, 19:03 last edited by
                  #8

                  Hi,

                  The usual logic is to create as many custom widgets as you need so in your case they will all have their own .ui files as well. Then you can use them as any other widget.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  2/8

                  20 Sept 2022, 12:45

                  6 unread
                  • Login

                  • Login or register to search.
                  2 out of 8
                  • First post
                    2/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved