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. I can't figure out what size polices to use to get widgets laid out the way I want

I can't figure out what size polices to use to get widgets laid out the way I want

Scheduled Pinned Locked Moved Unsolved General and Desktop
designerlayoutsizepolicy
3 Posts 2 Posters 1.4k Views
  • 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.
  • G Offline
    G Offline
    Guy Gizmo
    wrote on 3 Nov 2016, 18:36 last edited by
    #1

    The longer I've been designing UI using Qt / Qt Designer, the more I'm feeling frustrated trying to get it to work the way I want. I know how I want my UI to be laid out and make use of space as a user resizes a window, but what feels like it should take minutes ends up taking hours as I wrangle with Designer trying to get the size polices of all of my widgets correct, and it seems like I never get it right.

    Here is my latest example. I'm trying to make a dialog that looks roughly like this:

    my dialog

    What I have on the top part of this dialog is a group box containing a scroll view, which will have content dynamically added to it. The bottom half is another group box containing the buttons pictured and a list widget that will contain some number of items.

    What I'd like to have happen is that as the user increases the height of the window, it first causes the top group box to get larger until the entire contents of the scroll view is visible and there is no longer a need for a vertical scroll bar, at which point it starts increasing the size of the list widget.

    Based off the documentation for QSizePolicy, what seems like it ought to work is to set the vertical policy of the scroll view and its parent group box to "maximum" (which supposedly means that it shouldn't ever be larger than its size hint), and set the vertical policy of the list widget and its parent group box to "minimum" (which supposedly means it won't be made bigger unless no other widget can make use of the space).

    But that has a totally different effect than what I want. The top group box ends up being far, far too small, resizing itself to a fraction of the height of the scroll view's contents. And it just stays at that size, never growing larger or smaller. That just seems to make no damned sense. Note that I have tried setting the sizeAdjustPolicy property of the scroll area to "adjust to contents" and it makes no difference.

    After years of wrangling with this stuff, I still feel like I have no solid intuition of what the behavior of these widgets will be in regards to filling available space.

    Is there any way to get the result I want? Is it even possible purely using Qt Designer?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 3 Nov 2016, 18:49 last edited by
      #2

      what layouts are you placing in this widget?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      G 1 Reply Last reply 3 Nov 2016, 20:01
      0
      • V VRonin
        3 Nov 2016, 18:49

        what layouts are you placing in this widget?

        G Offline
        G Offline
        Guy Gizmo
        wrote on 3 Nov 2016, 20:01 last edited by
        #3

        @VRonin said in I can't figure out what size polices to use to get widgets laid out the way I want:

        what layouts are you placing in this widget?

        I'm using QGridLayout

        1 Reply Last reply
        0

        1/3

        3 Nov 2016, 18:36

        • Login

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