[Qt-interest] How to layout with width-for-height ?

Martin Schröer gordon at gordonswelt.de
Wed Sep 16 21:34:19 CEST 2009


First see
http://qt.nokia.com/doc/4.5/layout.html#how-to-write-a-custom-layout-manager 

for a general overview.

The main thing is the implementation of setGeometry(const QRect &rect).
Example:

QLayout::setGeometry(rect);

QLayoutItem *item;

foreach (item, itemList)

{

        int x = rect.x();

        int y = rect.y();

        int w = rect.width();

        int h = rect.height();


       // do something, calculate coords for every item


       item->setGeometry(QRect(x, y, w, h));

}

Tadaa.

Martin

william.crocker at analog.com schrieb:
>> I was also struggling with an issue similar to yours.
>> In short words: i gave up looking a solution that
>> uses width-for-height and started implementing
>> a custom layout instead.
>>
>>     
>
> The best thing you could do would be to give
> us all a theoretical description of what you
> did and why.
>
> Bill
>
>   
>>> I have some widgets which can provide height-for-width.
>>> This is supported by the Qt layout system.
>>>
>>> But, I also have widgets which need to behave
>>> like width-for-height. This behavior is not supported
>>> by the Qt layout system.
>>>
>>> How do I layout, given the need for some widgets
>>> in the layout to exhibit width-for-height?
>>>
>>> Obviously I would like to keep it as simple as possible
>>> and use the existing Qt widget layout classes.
>>>
>>> Thanks in advance.
>>>
>>> Bill
>>>
>>>       
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>   




More information about the Qt-interest-old mailing list