[Qt-interest] Qt Layout Squashing

Ian Thomson Ian.Thomson at iongeo.com
Tue Mar 9 18:13:55 CET 2010


Hi,

Turns out QStackedLayout always returns false for hasHeightForWidth 
because it inherits it from QLayoutItem which has that default behaviour.

http://doc.trolltech.com/4.6/qlayoutitem.html#hasHeightForWidth

So I guess that means QStackedLayout does not support height for width. 
Other layout types (e.g. QBoxLayout) do have this reimplemented.

Probably not the answer you wanted. You can probably get around this by 
inheriting from QStackedLayout and implementing it.

Cheers,
Ian.

Dave Smith wrote:
> Ian Thomson wrote:
>> I vaguely remember reading something in the documentation about this, 
>> but I'm having trouble finding it now. It was something along the 
>> lines of when you use QWidget::heightForWidth, it can disable the 
>> minimum size constraints for the entire layout structure that contains 
>> the label. A multi-line label uses this function and can cause this 
>> effect.
> 
> That sounds like a good place to look, but why does it work when the 
> label is not in a QStackedWidget, and breaks when it is inside a 
> QStackedWidget?
> 
> I also tried placing the two QLabels in a QFrame (instead of a 
> QStackedWidget), and the problem does not appear.
> 
> --Dave




More information about the Qt-interest-old mailing list