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 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 Online
    JonBJ Online
    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
          • JonBJ JonB

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

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

            @JonB What layout should I use? Also, my bad but here's the missing top half of the object inspector:
            3c2e1761-d2b9-4b1f-8e70-db7c495ad2dd-image.png

            Pl45m4P 1 Reply Last reply
            0
            • Pl45m4P Pl45m4

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

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

              @Pl45m4 For the radio buttons, I just want to place them over certain parts of the map to indicate where the samples are taken. Clicking on one of them would change the top label from PO1 (default) to PO5.

              Oh, and set the policy like what you said but they still haven't expanded yet:
              01e71441-4073-47da-92f6-9b8f86c10d30-image.png

              1 Reply Last reply
              0
              • R Rangerguy128

                @JonB What layout should I use? Also, my bad but here's the missing top half of the object inspector:
                3c2e1761-d2b9-4b1f-8e70-db7c495ad2dd-image.png

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

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

                Also, my bad but here's the missing top half of the object inspector:

                From this perspective it doesn't look quite right what you've done.
                It looks that you haven't applied the layouts TO your widgets, but added new layouts on top of them. You still have the red-sign that stands for "I have no layout" :)

                horizontalLayout_2 should be the "build-in" layout of centralWidget.
                Same for verticalLayout and widget_2.

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

                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"

                See what I wrote here.
                E.g. to set a layout TO centralWidget and to make the layout work property with your window, right-click the row in Object Inspector that says MainWindow (the very first one). There you can select a layout easily, but you have to have content within your widget's bounds... you can't set a layout to an empty widget... Don't ask why... QtDesigner is not the perfect tool :)
                Therefore I've said you need to create your inner layouts and content, before you can apply a layout to your centralWidget or your new widget.

                Edit:

                Since you replied to @JonB , is this screenshot from Object Inspector the current setup or is everything working now? Does it look like my setup? No red signs?!


                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 said in Have the main UI remain fixed when expanding:

                  Also, my bad but here's the missing top half of the object inspector:

                  From this perspective it doesn't look quite right what you've done.
                  It looks that you haven't applied the layouts TO your widgets, but added new layouts on top of them. You still have the red-sign that stands for "I have no layout" :)

                  horizontalLayout_2 should be the "build-in" layout of centralWidget.
                  Same for verticalLayout and widget_2.

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

                  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"

                  See what I wrote here.
                  E.g. to set a layout TO centralWidget and to make the layout work property with your window, right-click the row in Object Inspector that says MainWindow (the very first one). There you can select a layout easily, but you have to have content within your widget's bounds... you can't set a layout to an empty widget... Don't ask why... QtDesigner is not the perfect tool :)
                  Therefore I've said you need to create your inner layouts and content, before you can apply a layout to your centralWidget or your new widget.

                  Edit:

                  Since you replied to @JonB , is this screenshot from Object Inspector the current setup or is everything working now? Does it look like my setup? No red signs?!

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

                  @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).
                  4add50a1-1c24-4aee-96b0-f9acb13dcd1d-image.png

                  8641fbf6-472c-4b9c-b95e-9accf25a8bac-image.png

                  The latter expands when maximized but for some reason, even after messing with the sieze policy, the map image doesnt expand with the black label.

                  S JonBJ Pl45m4P 3 Replies Last reply
                  2
                  • R Rangerguy128

                    @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).
                    4add50a1-1c24-4aee-96b0-f9acb13dcd1d-image.png

                    8641fbf6-472c-4b9c-b95e-9accf25a8bac-image.png

                    The latter expands when maximized but for some reason, even after messing with the sieze policy, the map image doesnt expand with the black label.

                    S Offline
                    S Offline
                    SimonSchroeder
                    wrote on last edited by
                    #25

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

                    the map image doesnt expand with the black label.

                    If the image is restricted by its height, it will not expand to the side. You might be able to fix this by putting the image inside a scroll area.

                    For the buttons on the left you might want to add a vertical spacer item at the bottom of the layout (which would add a lot of space at the bottom but prevent the buttons from being spread out).

                    1 Reply Last reply
                    1
                    • R Rangerguy128

                      @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).
                      4add50a1-1c24-4aee-96b0-f9acb13dcd1d-image.png

                      8641fbf6-472c-4b9c-b95e-9accf25a8bac-image.png

                      The latter expands when maximized but for some reason, even after messing with the sieze policy, the map image doesnt expand with the black label.

                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by JonB
                      #26

                      @Rangerguy128
                      Just to say, this (the second one) is much better! You always want to get rid of any "red no-entry" signs for missing layout shown in Object Inspector. Nothing will behave right till you do.

                      1 Reply Last reply
                      1
                      • R Rangerguy128

                        @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).
                        4add50a1-1c24-4aee-96b0-f9acb13dcd1d-image.png

                        8641fbf6-472c-4b9c-b95e-9accf25a8bac-image.png

                        The latter expands when maximized but for some reason, even after messing with the sieze policy, the map image doesnt expand with the black label.

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

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

                        @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).

                        Yes the 2nd is the obviously the better one.
                        That's what I also described here:

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

                        The final result should look like this:

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

                        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.

                        I was asking this, because depending on what you want to do, you better use QGraphicsView or at least put your map in some scrollable widget as @SimonSchroeder suggested...

                        So if I understand correctly, you want to anchor those radio buttons to fixed postions on your map (on your image label) and then be able to toggle them and do something after that? Is that all?


                        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 said in Have the main UI remain fixed when expanding:

                          @Pl45m4 I have two windows just in case: one that was my own (the former), and the other following @JonB's instructions (the latter).

                          Yes the 2nd is the obviously the better one.
                          That's what I also described here:

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

                          The final result should look like this:

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

                          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.

                          I was asking this, because depending on what you want to do, you better use QGraphicsView or at least put your map in some scrollable widget as @SimonSchroeder suggested...

                          So if I understand correctly, you want to anchor those radio buttons to fixed postions on your map (on your image label) and then be able to toggle them and do something after that? Is that all?

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

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

                          So if I understand correctly, you want to anchor those radio buttons to fixed postions on your map (on your image label) and then be able to toggle them and do something after that? Is that all?

                          Yes, exactly what I'm trying to do! Can you demostrate it if possible? I'm trying to mess around with the app but I'm still a newbie on how it works.

                          M 1 Reply Last reply
                          0
                          • R Rangerguy128

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

                            So if I understand correctly, you want to anchor those radio buttons to fixed postions on your map (on your image label) and then be able to toggle them and do something after that? Is that all?

                            Yes, exactly what I'm trying to do! Can you demostrate it if possible? I'm trying to mess around with the app but I'm still a newbie on how it works.

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

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

                            you want to anchor those radio buttons to fixed postions on your map

                            The easy way is to anchor to the top-left corner because this position is fixed independently of the image size.

                            R 1 Reply Last reply
                            0
                            • M mpergand

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

                              you want to anchor those radio buttons to fixed postions on your map

                              The easy way is to anchor to the top-left corner because this position is fixed independently of the image size.

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

                              @mpergand Any way to do that? By top left corner, you mean of the image or the layout where the image is in?

                              M 1 Reply Last reply
                              0
                              • R Rangerguy128

                                @mpergand Any way to do that? By top left corner, you mean of the image or the layout where the image is in?

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

                                @Rangerguy128

                                You can create a widget outside of any layout.
                                It will be positioned at 0,0 of the parent widget you give:

                                auto frame=new QFrame(some parent widget):
                                frame->setFrameShape(QFrame::Box);
                                // you can move it then after
                                frame->move(10,10);

                                R 1 Reply Last reply
                                0
                                • M mpergand

                                  @Rangerguy128

                                  You can create a widget outside of any layout.
                                  It will be positioned at 0,0 of the parent widget you give:

                                  auto frame=new QFrame(some parent widget):
                                  frame->setFrameShape(QFrame::Box);
                                  // you can move it then after
                                  frame->move(10,10);

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

                                  @mpergand ah okay, so should I place my map and the radio buttons in a widget, and then apply the lines of code you mentioned on python? And the widget needs to be outside of the layout, right?

                                  M 1 Reply Last reply
                                  0
                                  • R Rangerguy128

                                    @mpergand ah okay, so should I place my map and the radio buttons in a widget, and then apply the lines of code you mentioned on python? And the widget needs to be outside of the layout, right?

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

                                    @Rangerguy128
                                    As a test you can set the parent to your map:

                                    auto frame=new QFrame(your map widget):

                                    and see how it looks.

                                    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