Qt-interest Archive, July 2007
Spacing between widgets in a layout
Message 1 in thread
I can't seem to figure out how to control the spacing between widgets in
a layout. I want to be able to create a layout, and have the widgets
around the edges not waste any space with their margins, but I can't
seem to figure out how this is done (see attached photo for what I'm
calling "wasted space". I have tried the following things, that don't
seem to have any effect:
1. Changing the the spacing and margins properties of the layout does
nothing to solve this problem. The spacing and margins report they are 0.
2. Changing the content margins of all the widgets in the layout itself
as well as the the central widget for the dock window. This also does
nothing and the content margins report that they have 0 space on the
top, left, bottom, and right.
3. Manually updating the layout every time a resize is done. This
doesn't seem to do anything (I also check all the previously mentioned
properties to see if they change on a resize, they don't).
Does anybody have any ideas? I don't understand what Qt properties is
causing all this wasted space in my layout. Thanks,
Chris Portka


Message 2 in thread
"Chris Portka" <cportka@xxxxxxxxxxxxxxx> wrote in message
news:f8835o$js6$1@xxxxxxxxxxxxxxxxxxxxx
>I can't seem to figure out how to control the spacing between widgets in
> a layout. I want to be able to create a layout, and have the widgets
> around the edges not waste any space with their margins, but I can't
> seem to figure out how this is done (see attached photo for what I'm
> calling "wasted space". I have tried the following things, that don't
> seem to have any effect:
> 1. Changing the the spacing and margins properties of the layout does
> nothing to solve this problem. The spacing and margins report they are 0.
> 2. Changing the content margins of all the widgets in the layout itself
> as well as the the central widget for the dock window. This also does
> nothing and the content margins report that they have 0 space on the
> top, left, bottom, and right.
> 3. Manually updating the layout every time a resize is done. This
> doesn't seem to do anything (I also check all the previously mentioned
> properties to see if they change on a resize, they don't).
> Does anybody have any ideas? I don't understand what Qt properties is
> causing all this wasted space in my layout. Thanks,
> Chris Portka
Try setting the alignment.
What type of layout is it? If it's a QVBoxLayout, try setting the alignment
the AlignTop. I've had this help in some cases.
--
[ signature omitted ]
Message 3 in thread
On 7/25/07, Chris Portka <cportka@xxxxxxxxxxxxxxx> wrote:
>
> I can't seem to figure out how to control the spacing between widgets in
> a layout. I want to be able to create a layout, and have the widgets
> around the edges not waste any space with their margins, but I can't
> seem to figure out how this is done (see attached photo for what I'm
> calling "wasted space".
<snip>
Looking at the attached image, I agree that the space between the widgets
looks poor, but the question is, what do you want Qt to do with that space?
Do you want any leftover space to be consolidated at the bottom of the
window, do you want the plot to take all the space that the label doesn't
need?
Also, what layout are you using, and what are the layouts and widgets inside
of it? Looking at the image, it looks like you have a QVBoxLayout with two
widgets: one that is the plot, and another that has the Go button and a
series of labels. Is this correct?
Tom