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. Have the main UI remain fixed when expanding
Forum Updated to NodeBB v4.3 + New Features

Have the main UI remain fixed when expanding

Scheduled Pinned Locked Moved Unsolved General and Desktop
33 Posts 6 Posters 4.8k Views 3 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.
  • R Offline
    R Offline
    Rangerguy128
    wrote on last edited by
    #1

    Need some advice on expanding the main app's UI which i created in QT Designer. Here'swhat it looks like:

    0760ea34-da4c-4cd0-aafc-2782983c8b40-image.png

    However, when expanding as I previewed it, this is what it looks like now:
    0d2fc7fb-58ce-4858-9f24-5a738f76b49b-image.png

    Are there any solutions to this? Do I have to mess around with QT Designer or are a few lines of code in Python good enough? Also, while not related to the topic, I can't figure out as to why I can't resize the vertical widget on the left where the four pushbuttons are placed. It looks like it needs a 5th button but I only want 4 for now.

    Pl45m4P 1 Reply Last reply
    0
    • R Rangerguy128

      Need some advice on expanding the main app's UI which i created in QT Designer. Here'swhat it looks like:

      0760ea34-da4c-4cd0-aafc-2782983c8b40-image.png

      However, when expanding as I previewed it, this is what it looks like now:
      0d2fc7fb-58ce-4858-9f24-5a738f76b49b-image.png

      Are there any solutions to this? Do I have to mess around with QT Designer or are a few lines of code in Python good enough? Also, while not related to the topic, I can't figure out as to why I can't resize the vertical widget on the left where the four pushbuttons are placed. It looks like it needs a 5th button but I only want 4 for now.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Rangerguy128

      What layouts do you use?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      R 1 Reply Last reply
      2
      • Pl45m4P Pl45m4

        @Rangerguy128

        What layouts do you use?

        R Offline
        R Offline
        Rangerguy128
        wrote on last edited by Rangerguy128
        #3

        @Pl45m4 I only used vertical layout where I could store the buttons and the label (Also, I managed to fix the layout size, atleast). As for the map, its radio buttons and the label on top of it, I used a display widget (label) for them. DO I have to place the labels over the layouts for it to work?

        Pl45m4P 1 Reply Last reply
        0
        • R Rangerguy128

          @Pl45m4 I only used vertical layout where I could store the buttons and the label (Also, I managed to fix the layout size, atleast). As for the map, its radio buttons and the label on top of it, I used a display widget (label) for them. DO I have to place the labels over the layouts for it to work?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Rangerguy128 said in Have the main UI remain fixed when expanding:

          I used a display widget (label) for them. DO I have to place the labels over the layouts for it to work?

          You need to put the label that shows your map in a layout that scales with your main window.
          Does your centralWidget in Designer have a layout or do you see this red circle "warning" icon next to centralWidget in Object Inspector?


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          Ronel_qtmasterR 1 Reply Last reply
          1
          • Pl45m4P Pl45m4

            @Rangerguy128 said in Have the main UI remain fixed when expanding:

            I used a display widget (label) for them. DO I have to place the labels over the layouts for it to work?

            You need to put the label that shows your map in a layout that scales with your main window.
            Does your centralWidget in Designer have a layout or do you see this red circle "warning" icon next to centralWidget in Object Inspector?

            Ronel_qtmasterR Offline
            Ronel_qtmasterR Offline
            Ronel_qtmaster
            wrote on last edited by
            #5

            @Pl45m4 it is simple.As you are using a MainWindow, do:
            ui->CentralWidget->setLayout(ui->your_layout);

            then the layout should contain your label

            Pl45m4P R 2 Replies Last reply
            0
            • Ronel_qtmasterR Ronel_qtmaster

              @Pl45m4 it is simple.As you are using a MainWindow, do:
              ui->CentralWidget->setLayout(ui->your_layout);

              then the layout should contain your label

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #6

              @Ronel_qtmaster said in Have the main UI remain fixed when expanding:

              @Pl45m4 it is simple. As you are using a MainWindow, do

              Me? Not my topic :)

              ui->CentralWidget->setLayout(ui->your_layout);
              then the layout should contain your label

              @Rangerguy128 has probably multiple layouts (at least one more containing the buttons). So just setting one layout as central layout might not be the best solution.
              Both/all layouts have to get connected first. Then you can set the top-most as central layout


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              Ronel_qtmasterR R 2 Replies Last reply
              1
              • Pl45m4P Pl45m4

                @Ronel_qtmaster said in Have the main UI remain fixed when expanding:

                @Pl45m4 it is simple. As you are using a MainWindow, do

                Me? Not my topic :)

                ui->CentralWidget->setLayout(ui->your_layout);
                then the layout should contain your label

                @Rangerguy128 has probably multiple layouts (at least one more containing the buttons). So just setting one layout as central layout might not be the best solution.
                Both/all layouts have to get connected first. Then you can set the top-most as central layout

                Ronel_qtmasterR Offline
                Ronel_qtmasterR Offline
                Ronel_qtmaster
                wrote on last edited by
                #7

                @Pl45m4 THANKS.I said the layout which has the label for image because it is the one he asked for

                1 Reply Last reply
                0
                • Pl45m4P Pl45m4

                  @Ronel_qtmaster said in Have the main UI remain fixed when expanding:

                  @Pl45m4 it is simple. As you are using a MainWindow, do

                  Me? Not my topic :)

                  ui->CentralWidget->setLayout(ui->your_layout);
                  then the layout should contain your label

                  @Rangerguy128 has probably multiple layouts (at least one more containing the buttons). So just setting one layout as central layout might not be the best solution.
                  Both/all layouts have to get connected first. Then you can set the top-most as central layout

                  R Offline
                  R Offline
                  Rangerguy128
                  wrote on last edited by
                  #8

                  @Pl45m4 I see, so should I use one layout where I can throw in all of my widgets, labels, etc.? Or can I use multiple layouts and place them beside eachother? For example, placing a vertical layout on the left of the window, and a grid layout on the right. For clarirication, as seen on my window, the only layoyt I used there was the vertical to contain both the "Parameter" label and the QPushbuttons. Neither the top black label nor the map image are contained in a layout.

                  M Pl45m4P 2 Replies Last reply
                  0
                  • R Rangerguy128

                    @Pl45m4 I see, so should I use one layout where I can throw in all of my widgets, labels, etc.? Or can I use multiple layouts and place them beside eachother? For example, placing a vertical layout on the left of the window, and a grid layout on the right. For clarirication, as seen on my window, the only layoyt I used there was the vertical to contain both the "Parameter" label and the QPushbuttons. Neither the top black label nor the map image are contained in a layout.

                    M Offline
                    M Offline
                    mpergand
                    wrote on last edited by mpergand
                    #9

                    @Rangerguy128 said in Have the main UI remain fixed when expanding:

                    Or can I use multiple layouts and place them beside eachother?

                    Use a HLayout as root, then add 2 VLayouts to it, one for your buttons and another for your image and label.

                    R 1 Reply Last reply
                    3
                    • R Rangerguy128

                      @Pl45m4 I see, so should I use one layout where I can throw in all of my widgets, labels, etc.? Or can I use multiple layouts and place them beside eachother? For example, placing a vertical layout on the left of the window, and a grid layout on the right. For clarirication, as seen on my window, the only layoyt I used there was the vertical to contain both the "Parameter" label and the QPushbuttons. Neither the top black label nor the map image are contained in a layout.

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on last edited by Pl45m4
                      #10

                      @Rangerguy128 said in Have the main UI remain fixed when expanding:

                      Or can I use multiple layouts and place them beside eachother?

                      Yes, cascading layouts.
                      How you set them up depends on how your elements should behave and how your GUI should look like.
                      To get what you illustrate above, I would group your buttons in a vertical layout, put the vertical layout in a horizontal layout. And then move the label and the other label, which holds your map to the right of our button layout. So that they are also included in the horizontal layout
                      At last set the horizontal layout as layout for centralWidget

                      To do this in Designer you might have to remove the current layout and start to order your widgets from scratch.
                      Select all your buttons, right click, pick "Lay out vertically". Right click on the empty area, select "Lay out horizonal" (this should apply a QHBoxLayout to centralWidget) and then you drag the label (or layout with your labels) to your position in the layout.

                      Neither the top black label nor the map image are contained in a layout.

                      That is the reason why the map does not scale or move with your window.


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      1
                      • Ronel_qtmasterR Ronel_qtmaster

                        @Pl45m4 it is simple.As you are using a MainWindow, do:
                        ui->CentralWidget->setLayout(ui->your_layout);

                        then the layout should contain your label

                        R Offline
                        R Offline
                        Rangerguy128
                        wrote on last edited by
                        #11

                        @Ronel_qtmaster Where can I find those options on QT Designer? My apologies if I'm blind but I can't find them. One guy on the internet suggested on right clicking the main window but no luck. Do you mind showing them with a screenshot?

                        Pl45m4P 1 Reply Last reply
                        0
                        • R Rangerguy128

                          @Ronel_qtmaster Where can I find those options on QT Designer? My apologies if I'm blind but I can't find them. One guy on the internet suggested on right clicking the main window but no luck. Do you mind showing them with a screenshot?

                          Pl45m4P Offline
                          Pl45m4P Offline
                          Pl45m4
                          wrote on last edited by
                          #12

                          @Rangerguy128

                          See here

                          • https://doc.qt.io/qt-6/designer-layouts.html

                          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                          ~E. W. Dijkstra

                          1 Reply Last reply
                          3
                          • M mpergand

                            @Rangerguy128 said in Have the main UI remain fixed when expanding:

                            Or can I use multiple layouts and place them beside eachother?

                            Use a HLayout as root, then add 2 VLayouts to it, one for your buttons and another for your image and label.

                            R Offline
                            R Offline
                            Rangerguy128
                            wrote on last edited by
                            #13

                            @mpergand How do I add thwo vertical layouts in one horizontal layout? I did what you say but for some reason, neither of thw two are seperated, as if both were on top of another.

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              Rangerguy128
                              wrote on last edited by Rangerguy128
                              #14

                              Did another way by having two vertical layouts with their own contents (on that has the qpushbuttons and the other that had the map and the top black label), and this is what I'm getting:
                              6f44503e-9ae0-4ea8-b487-ae55281132ab-image.png

                              Also, when, I tried to add radio buttons to the map (already placed in the vertical layout), this happens:
                              e09a5082-69c2-4957-b84a-7ff8f2adaf0d-image.png

                              I'm still new with QT designer so I really don't know what I'm supposed to do. Even with youtube videos, I can't seem to find an answer.

                              Oh, and forgot to mention that for the vertical layout with the pushbuttons, it has a widget intergrated so I could place the buttons and the top blue label in order.

                              Pl45m4P 1 Reply Last reply
                              0
                              • R Rangerguy128

                                Did another way by having two vertical layouts with their own contents (on that has the qpushbuttons and the other that had the map and the top black label), and this is what I'm getting:
                                6f44503e-9ae0-4ea8-b487-ae55281132ab-image.png

                                Also, when, I tried to add radio buttons to the map (already placed in the vertical layout), this happens:
                                e09a5082-69c2-4957-b84a-7ff8f2adaf0d-image.png

                                I'm still new with QT designer so I really don't know what I'm supposed to do. Even with youtube videos, I can't seem to find an answer.

                                Oh, and forgot to mention that for the vertical layout with the pushbuttons, it has a widget intergrated so I could place the buttons and the top blue label in order.

                                Pl45m4P Offline
                                Pl45m4P Offline
                                Pl45m4
                                wrote on last edited by
                                #15

                                @Rangerguy128

                                Can you show the Object Inspector please? So we can see what your current setup is


                                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                ~E. W. Dijkstra

                                R 1 Reply Last reply
                                0
                                • Pl45m4P Pl45m4

                                  @Rangerguy128

                                  Can you show the Object Inspector please? So we can see what your current setup is

                                  R Offline
                                  R Offline
                                  Rangerguy128
                                  wrote on last edited by
                                  #16

                                  @Pl45m4 Here it is: 084fc32f-6976-4691-8408-dd803d86b320-image.png

                                  Also, had to include widgets to the layouts just so I could add in the radio buttons.

                                  JonBJ Pl45m4P 2 Replies Last reply
                                  0
                                  • R Rangerguy128

                                    @Pl45m4 Here it is: 084fc32f-6976-4691-8408-dd803d86b320-image.png

                                    Also, had to include widgets to the layouts just so I could add in the radio buttons.

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #17

                                    @Rangerguy128
                                    You should start by setting a layout on the widget there which has a red "no-entry" symbol on it.

                                    R 1 Reply Last reply
                                    2
                                    • R Rangerguy128

                                      @Pl45m4 Here it is: 084fc32f-6976-4691-8408-dd803d86b320-image.png

                                      Also, had to include widgets to the layouts just so I could add in the radio buttons.

                                      Pl45m4P Offline
                                      Pl45m4P Offline
                                      Pl45m4
                                      wrote on last edited by
                                      #18

                                      @Rangerguy128

                                      It's not that hard. As I told you, start with the inner layouts, then group them in layouts together until you have your desired design.

                                      Start like this:
                                      I created 4 buttons and organized them in a verticalLayout. Next I created two labels, representing your map (in my case yellow area) and your text above your map.
                                      After that I created an empty QWidget (blue) and placed it somewhere on the mainWindow. As you can see, my QWidget widget and centralWidget also have no layout like yours.
                                      firstStep.png

                                      In the next steps you can add more widgets like your QRadioButtons. I grouped them in their own vertical layout.

                                      Finally you put all your stuff together:

                                      Order your widgets like this

                                      secondStep.png

                                      and right-click in object inspector (on the left) on your QWidget widget, click "Lay out" and "vertical". Then do the same on your QMainWindow where your select "Lay out horizontal"

                                      The final result should look like this:

                                      thirdStep.png

                                      Everything moves with your window now and should resize properly.
                                      Later you can add more buttons or whatever you like to the existing layouts, or you break them, add new layouts or re-arrange them.
                                      You can also see that widget as well as centralWidget both don't have the "no layout"-warning-sign anymore.


                                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                      ~E. W. Dijkstra

                                      R 1 Reply Last reply
                                      3
                                      • Pl45m4P Pl45m4

                                        @Rangerguy128

                                        It's not that hard. As I told you, start with the inner layouts, then group them in layouts together until you have your desired design.

                                        Start like this:
                                        I created 4 buttons and organized them in a verticalLayout. Next I created two labels, representing your map (in my case yellow area) and your text above your map.
                                        After that I created an empty QWidget (blue) and placed it somewhere on the mainWindow. As you can see, my QWidget widget and centralWidget also have no layout like yours.
                                        firstStep.png

                                        In the next steps you can add more widgets like your QRadioButtons. I grouped them in their own vertical layout.

                                        Finally you put all your stuff together:

                                        Order your widgets like this

                                        secondStep.png

                                        and right-click in object inspector (on the left) on your QWidget widget, click "Lay out" and "vertical". Then do the same on your QMainWindow where your select "Lay out horizontal"

                                        The final result should look like this:

                                        thirdStep.png

                                        Everything moves with your window now and should resize properly.
                                        Later you can add more buttons or whatever you like to the existing layouts, or you break them, add new layouts or re-arrange them.
                                        You can also see that widget as well as centralWidget both don't have the "no layout"-warning-sign anymore.

                                        R Offline
                                        R Offline
                                        Rangerguy128
                                        wrote on last edited by
                                        #19

                                        @Pl45m4 I did what you told me to do and so far, it works, although I hvae three questions. Why are the pushbuttons and the blue label all spaced out, why doesnt the map image (Changed it for a different one) expand along with the balck label, and how can I place the radio buttons over the map? Here's a screenshot so that you can take a better look:
                                        d041d43d-7dc0-4534-8319-43e321b22fb2-image.png

                                        Pl45m4P 1 Reply Last reply
                                        0
                                        • R Rangerguy128

                                          @Pl45m4 I did what you told me to do and so far, it works, although I hvae three questions. Why are the pushbuttons and the blue label all spaced out, why doesnt the map image (Changed it for a different one) expand along with the balck label, and how can I place the radio buttons over the map? Here's a screenshot so that you can take a better look:
                                          d041d43d-7dc0-4534-8319-43e321b22fb2-image.png

                                          Pl45m4P Offline
                                          Pl45m4P Offline
                                          Pl45m4
                                          wrote on last edited by Pl45m4
                                          #20

                                          @Rangerguy128 said in Have the main UI remain fixed when expanding:

                                          Why are the pushbuttons and the blue label all spaced out,

                                          Because they all take the space equally and don't grow vertically. QPushButtons have a fixed vertical size by default. Set sizePolicy of your buttons to vertical: Expanding (you can do it in Designer's property editor).

                                          why doesnt the map image (Changed it for a different one) expand along with the balck label

                                          I think it's the same reason as with your buttons. Change the sizePolicy
                                          Do you really want to stretch the image so the width-height-ratio changes?

                                          how can I place the radio buttons over the map?

                                          Then you can't put them in a layout.

                                          What is your goal after all? What do you want to do with this map and these "radio buttons"?
                                          There might be a better way, depending on what you have in mind.


                                          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                          ~E. W. Dijkstra

                                          R 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