PDA

View Full Version : QLayout alignment stretch



bunjee
26th October 2007, 21:24
In a QVBoxLayout :

Is it possible both to align left/right and keep the stretching value of a given widget ?

wysota
26th October 2007, 23:50
Align what? The vertical layout aligns vertically, so no left-right here... And what do you mean by "stretching value"?

bunjee
27th October 2007, 07:45
My bad, I was asking with QHBoxLayout in mind.


mHBoxLayout->AddWidget(lineEdit, 10, Qt::AlignLeft);

In this case the "stretching value" is 10 and the widget is aligned on the left.
Problem is since it's aligned to the left it wont stretch anymore.
What if for example we want the widget to expand to a certain value without occupying the whole space of a layout.

I'm not sure I'm making sense so let me give you an example :

If I have a QTextEdit paragraph and I want to align the paragraph to the left by keeping the stretching at the same time. How am I suppose to achieve this ? in the layout ? in the QTextEdit widget ?

Thanks.

wysota
27th October 2007, 21:24
The stretch factor only makes sense if you have more widgets in the layout. If you want to limit the expansion of a widget, just set its maximum size.