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



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



  • what layouts are you placing in this widget?



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.