[Qt-interest] Reasoning behind size-policy difference between layout and splitter?

K. Frank kfrank29.c at gmail.com
Sun Mar 28 04:03:51 CEST 2010


Julien -

Thank you.

On Sat, Mar 27, 2010 at 7:07 PM, Julien Cugnière
<julien.cugniere at gmail.com> wrote:
> 2010/3/27 K. Frank <kfrank29.c at gmail.com>:
>> I am aware that (at least in this situation) changing the sizePolicy
>> of the splitter
>> to "Expanding, Expanding" from its default setting of "Expanding, Preferred"
>> makes the splitter behave like the layout.  But knowing about that setting,
>> and being able to change it, still isn't giving me the intuition about how the
>> resizing framework is designed to work.
>
> The difference is basically that the splitter is not a layout : it's a
> widget.

Yes, I guess I was drawing too much of a false analogy between layouts and
splitters.

> When using the horizontal layout, the QTableView's are
> children of the top-level widget. Their size only depends on their
> sizePolicy, which is "Expanding, Expanding" by default. The horizontal
> layout itself has no sizePolicy. It requests the size requested by its
> elements.

Okay, layouts have no sizePolicies of their own.

> On the other hand, when you use a splitter, you add another level of
> widget in the equation : the QTableView's are child of the splitter
> widget, which is a child of the top-level widget. So their size
> depends on their sizePolicy, but also on that of the splitter, which
> is "Expanding, Preferred" by default.

And splitters -- which are widgets in their own right -- do have their own
size policies.

> So the QTableView's requests as
> much vertical size as possible from the splitter, but the splitter
> doesn't requests as much as possible from the top-level widget. So
> they are basically limited to the size of the splitter.
>
> I'm not sure why the splitter is "Expanding, Preferred" by default.
> Maybe there are situations were that makes sense, but in your case, it
> doesn't really.

And, indeed, if I change the sizePolicy of the splitter to "Expanding,
Expanding"
I do get what I want.

> Hope that helps to clarify things a bit !

Yes it does, thanks.

> Julien Cugnière




More information about the Qt-interest-old mailing list