[Qt-interest] Reasoning behind size-policy difference between layout and splitter?
Julien Cugnière
julien.cugniere at gmail.com
Sun Mar 28 00:07:43 CET 2010
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. 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.
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. 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.
Hope that helps to clarify things a bit !
--
Julien Cugnière
More information about the Qt-interest-old
mailing list