[Qt-interest] QVBoxLayout widget spacing
Robert Hairgrove
evorgriahr at hispeed.ch
Sun May 2 11:09:34 CEST 2010
Harold Hausman wrote:
> Hi,
>
> I'm trying to use a QVBoxLayout to lay out some custom widgets I've
> created and I have some questions.
>
> The custom widgets have a fixed height, as in setFixedHeight( 200 ).
> When I add the first widget to the QVBoxLayout, it lays it out in the
> middle of the layouts's area (the layout is taller than the widget I'm
> adding in). This isn't what I want.
>
> I'd like the layout to instead add the widget at the top of the
> layout. Is there a way to set it up to do this? Essentially, instead
> of evenly spacing the child widgets out, I'd like the layout to just
> use the available space from top to bottom as widgets are added (with
> all the unused space collected at the bottom).
>
> Thanks in advance for any insight,
> -Harold
In QtDesigner I always do this by adding a vertical spacer at the bottom
of the widgets inside of the layout. It will then "eat" any leftover
space not occupied by the other widgets. Never did it in code, though it
must be easy to do.
More information about the Qt-interest-old
mailing list