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. frame won't stretch in vbox layout
Forum Updated to NodeBB v4.3 + New Features

frame won't stretch in vbox layout

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 2.3k 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.
  • H Offline
    H Offline
    HamishM
    wrote on last edited by
    #1

    I have a simple form using a vertical box layout, containing two frames. Each frame has a vertical box layout of its own, and contains a QTableWidget. The top table widget has a maximum height set. Here's a picture:

    https://imgur.com/a/h7xaELN

    I expect the bottom table widget to expand to fill the form, but it doesn't. I have not found any combination of size policies on the frames and table widgets that will make this work.

    I've posted the form .ui file here:
    https://pastebin.com/13iRVQcU

    Any ideas?

    Thanks
    Hamish

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      When i try your UI files, the lower frame follows the dialog just fine.
      They split the size 50/50 as instructed.

      What is the goal ?
      you want the lower frame to take up most space so the top one is only the fixed size you have set on it ?

      H 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        When i try your UI files, the lower frame follows the dialog just fine.
        They split the size 50/50 as instructed.

        What is the goal ?
        you want the lower frame to take up most space so the top one is only the fixed size you have set on it ?

        H Offline
        H Offline
        HamishM
        wrote on last edited by
        #3

        @mrjj yes I want the bottom frame to take up the extra space. Why is it only splitting 50/50? I have the vertical stretch factors set to zero everywhere.

        mrjjM 1 Reply Last reply
        0
        • H HamishM

          @mrjj yes I want the bottom frame to take up the extra space. Why is it only splitting 50/50? I have the vertical stretch factors set to zero everywhere.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @HamishM
          Hi
          0,0 means split equally.
          you want something like else
          alt text

          alt text

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HamishM
            wrote on last edited by
            #5

            I don't think that is the right answer. There is no point in having the QVBoxLayout if I have to manage the sizes myself by adjusting the stretch factors.

            If I set the minimum height on the upper frame instead of the widget inside it, then I get the desired result. Why isn't the upper QFrame passing on size as the size of its contents?

            mrjjM 1 Reply Last reply
            0
            • H HamishM

              I don't think that is the right answer. There is no point in having the QVBoxLayout if I have to manage the sizes myself by adjusting the stretch factors.

              If I set the minimum height on the upper frame instead of the widget inside it, then I get the desired result. Why isn't the upper QFrame passing on size as the size of its contents?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @HamishM
              Im not sure what you mean. the stretch factor adjusts the space allocated to each widget and you need only to set this once to specify how it should be shared.
              well layouts like to share the space so if entire dialog leaves more space then it will use it.

              H 1 Reply Last reply
              1
              • mrjjM mrjj

                @HamishM
                Im not sure what you mean. the stretch factor adjusts the space allocated to each widget and you need only to set this once to specify how it should be shared.
                well layouts like to share the space so if entire dialog leaves more space then it will use it.

                H Offline
                H Offline
                HamishM
                wrote on last edited by
                #7

                @mrjj so how do I specify that either frame should use as much space as possible?

                There may be scenarios where the bottom table has a maximum height instead, so I can't just set a stretch of 0,1.

                As I said, it works when I put the maximum height on the frame instead of the table widget inside the frame. I don't understand why the frame isn't shrinking itself to the size of the table widget and then the other frame gets the extra space.

                JKSHJ 1 Reply Last reply
                0
                • H HamishM

                  @mrjj so how do I specify that either frame should use as much space as possible?

                  There may be scenarios where the bottom table has a maximum height instead, so I can't just set a stretch of 0,1.

                  As I said, it works when I put the maximum height on the frame instead of the table widget inside the frame. I don't understand why the frame isn't shrinking itself to the size of the table widget and then the other frame gets the extra space.

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  @HamishM said in frame won't stretch in vbox layout:

                  I don't understand why the frame isn't shrinking itself to the size of the table widget and then the other frame gets the extra space.

                  Because, by default, all QFrames try to expand to get a share of the available space.

                  If you want the frame to shrink to its contents, set the frame's Size Policy to Maximum.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  2

                  • Login

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