PDA

View Full Version : precise definition of layout algorithms!



33333
5th June 2012, 16:39
OK so every Layout is different, but all QtGui Layouts will use the following widget properties in determining their position on the screen: sizeHint, minimumSize, maximumSize, minimumSizeHint, sizePolicy. This section of the documentation alludes to a common algorithm or set of semantices for these properties http://doc.qt.nokia.com/4.7/layout.html#adding-widgets-to-a-layout. However 1. It must be innacurate because it cant apply to more complicated layouts? 2. I cant help but think it is innaccurate any way because it states:


1. All the widgets will initially be allocated an amount of space in accordance with their QWidget::sizePolicy() and QWidget::sizeHint().

This cannot be correct because elsewhere in the documentation it is stated sizePolicy reinterprets the meaning of size hint (http://doc.qt.nokia.com/4.7/qsizepolicy.html#details); THERE IS NO SCOPE for reinterpreting anything in "will initially be allocated" - the widget is allocated a size not a min/max size and that size must, be according to the above statement, the size hint. So the statement should be:


1. All the widgets will initially be allocated an amount of space in accordance with their QWidget::sizeHint().

And then it should explain what happens if a widget has no size hint - which is possible (http://doc.qt.nokia.com/4.7/qwidget.html#sizeHint-prop).

Anyway I was wondering if anyone could point me in the direction of a more rigorous description of the layot algorithms - short of the source.

Thanks.

wysota
6th June 2012, 00:48
This cannot be correct because elsewhere in the documentation it is stated sizePolicy reinterprets the meaning of size hint
I would say it complements the meaning of size hint.


THERE IS NO SCOPE for reinterpreting anything in "will initially be allocated" - the widget is allocated a size not a min/max size and that size must, be according to the above statement, the size hint.
I totally fail to see your point. A layout takes into consideration the size hint, the size policy and the stretch of the widget. The result is something that satisfies all of the three for every widget in the layout.


And then it should explain what happens if a widget has no size hint - which is possible (http://doc.qt.nokia.com/4.7/qwidget.html#sizeHint-prop).
A widget always has a size hint. It might be invalid but the hint is there (it's treated as 0).


Anyway I was wondering if anyone could point me in the direction of a more rigorous description of the layot algorithms - short of the source.
If you ask a specific question, you'll get a specific answer. I personally think the algorithm is pretty simple and easy to understand. Most of it is described in the docs for the size policy probably.

33333
6th June 2012, 03:25
THERE IS NO SCOPE for reinterpreting anything in "will initially be allocated" - the widget is allocated a size not a min/max size and that size must, be according to the above statement, the size hint.
I totally fail to see your point. A layout takes into consideration the size hint, the size policy and the stretch of the widget. The result is something that satisfies all of the three for every widget in the layout.

Hard to see out of context but the first step of the apparent algorithm is to assign a size to all widgets based on "size policy and size hint". My point was... I am asserting this is innaccurate. It just assigns size hint, size policy has nothing to do with it at this point.


(it's treated as 0).

Excellent thanks.

I agree it seems to be fairly simple and intuitive.