Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. need to modify layout fill policy
Qt 6.12 LTS is out! See what's new in the release blog

need to modify layout fill policy

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 1.9k Views 2 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.
  • M Offline
    M Offline
    mpergand
    wrote on last edited by
    #2

    Try to set the vertical size policy to "Expanding"

    BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

    Kent-DorfmanK 2 Replies Last reply
    0
    • M mpergand

      Try to set the vertical size policy to "Expanding"

      BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

      Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #3

      @mpergand said in need to modify layout fill policy:

      Try to set the vertical size policy to "Expanding"

      no joy. size policies of the widgets in the layout make no difference. I did locate a "layout alignment" option in the designer pulldown, but regardless of what I do, it only wants to apply to the first (top) mixer widget, the remaining mixers continue to be added spaced out instead of top aligned.

      Attached is the relevant widget tree. Each MixBar has its alignment alignment set to "top".
      second image is what it looks like, which is wrong.
      screen.jpg
      screen.jpg

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      0
      • M mpergand

        Try to set the vertical size policy to "Expanding"

        BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

        Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #4

        @mpergand said in need to modify layout fill policy:

        BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

        Actually that is opposite of what I want. I want it to only occupy necessary space, and align to the top of the container.

        The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

        J.HilkJ M 2 Replies Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          @mpergand said in need to modify layout fill policy:

          BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

          Actually that is opposite of what I want. I want it to only occupy necessary space, and align to the top of the container.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #5

          @Kent-Dorfman I always fight with the QLayouts myself especially in the case you describe.

          I would suggest, adding a 5th item to the layout, a QSpacer, that should expand and take up the available space from the hidden widgets


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          JonBJ 1 Reply Last reply
          2
          • Kent-DorfmanK Kent-Dorfman

            @mpergand said in need to modify layout fill policy:

            BTW, I made a test with QFrame and the standard beheavior is what you want, if only one frame is visible, it occupies the all space.

            Actually that is opposite of what I want. I want it to only occupy necessary space, and align to the top of the container.

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

            @Kent-Dorfman said in need to modify layout fill policy:

            Actually that is opposite of what I want. I want it to only occupy necessary space, and align to the top of the container.

            In this case, add a spacer as @J-Hilk suggested.

            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @Kent-Dorfman I always fight with the QLayouts myself especially in the case you describe.

              I would suggest, adding a 5th item to the layout, a QSpacer, that should expand and take up the available space from the hidden widgets

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

              @J-Hilk , @Kent-Dorfman
              I agree that with Qt it seems best to add an extra item at the end (vertically or horizontally), to cause previous stuff to "squeeze" into previous area. (Not that it seems ideal to me, but I think that's what peeps do.) However, you said QSpacer (I think that's QSpacerItem), I don't know whether the default is as small as possible? I would recommend void QBoxLayout::addStretch(int stretch = 0)?

              J.HilkJ 1 Reply Last reply
              0
              • JonBJ JonB

                @J-Hilk , @Kent-Dorfman
                I agree that with Qt it seems best to add an extra item at the end (vertically or horizontally), to cause previous stuff to "squeeze" into previous area. (Not that it seems ideal to me, but I think that's what peeps do.) However, you said QSpacer (I think that's QSpacerItem), I don't know whether the default is as small as possible? I would recommend void QBoxLayout::addStretch(int stretch = 0)?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #8

                @JonB said in need to modify layout fill policy:

                QSpacer (I think that's QSpacerItem),

                I don't know for sure, I just added a Q before the Item description, you know, the Qt -way :D


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                0
                • Kent-DorfmanK Offline
                  Kent-DorfmanK Offline
                  Kent-Dorfman
                  wrote on last edited by
                  #9

                  Spacer at bottom?

                  Brilliant! Will give it a try and report back. ;^)

                  The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

                  M 1 Reply Last reply
                  0
                  • Kent-DorfmanK Kent-Dorfman

                    Spacer at bottom?

                    Brilliant! Will give it a try and report back. ;^)

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

                    @Kent-Dorfman
                    Sure it works:
                    https://forum.qt.io/topic/137161/qt-creator-incorrect-layout

                    1 Reply Last reply
                    0
                    • Kent-DorfmanK Offline
                      Kent-DorfmanK Offline
                      Kent-Dorfman
                      wrote on last edited by
                      #11

                      inserting vertical spacer at bottom of layout did fix the problem Thanks!
                      and it wasn't as "hackish" as I had worried the solution would be. :^)

                      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

                      JonBJ 1 Reply Last reply
                      0
                      • Kent-DorfmanK Kent-Dorfman

                        inserting vertical spacer at bottom of layout did fix the problem Thanks!
                        and it wasn't as "hackish" as I had worried the solution would be. :^)

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

                        @Kent-Dorfman
                        This question does get asked many times. ISTM that layouts should offer the functionality without user having to put a space/stretch at the other end of the layout to achieve this. I should be able to say "align/place all things from left/right/top/bottom one after the other, do not expand/move them", it's pretty common to want this....

                        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
                        • Unsolved