Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-10-12 02:28:26


John Torjo wrote:

>
>>>
>>>I do think that every now and then, you do need to specify dimensions.
>>>For instance, when specifying a button's width (in case you want it
>>>fixed).
>>
>>
>> Why would you want to have it fixed to absolute values? Say, in Qt if you
>> want buttons to not grow when you resize dialog you set its "size policy"
>> to either "Fixed" or "Maximum". You don't need to specify absolute
>> values.
>>
>
> I'm not sure I understand: once you set a "size policy" to "fixed", it
> seems that you would need to set a fixed size (for a button, for
> instance).

"you would need" -- that's the key, "you" don't need to compute the size, Qt
will do it itself. Each widget has sizeHint method that return preferred
size. For button, that's that length of the text plus some extra space.
If you set size policy to "fixed", Qt won't ever try to resize the widget
above it's sizeHint. Works pretty nice.

> (question aside: can you choose the "size policy" for each dimension
> like, left,top,width,height, or for the whole widget?)

There's separate size policy for width and height. As for left/top -- that's
outside of widget control and in control of its parent. Of course the
parent typically use the layout classes to control that, and does not set
absolute positions.

In fact, absolute positions are almost always wrong. Imagine you set a
button width to fixed value, and day later I translate the text on button
to Russian, possibly increasing its length twofold. That's why automatic
layout is not just nice to have, but a requirement.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk