[Qt-interest] Problem with Layout, it does not resize itself

Christian Gagneraud cgagneraud at techworks.ie
Wed Feb 17 14:07:21 CET 2010


On 02/17/2010 12:14 PM, Maximilien Renard wrote:
> Dear Qt Users,
>
> I'm having some trouble using layouts.
>
> Basically, this is what I have in a widget which is in a QScrollArea
> which is set as the centralWidget of my MainApplication :
>
> Widget::Widget() : QWidget() {
> QVBoxLayout * vBoxLayout = new QVBoxLayout;
> QLabel * label = new QLabel("LABEL");
> vBoxLayout->addWidget(label);
> QFormLayout * formLayout = new QFormLayout;
> formLayout->addRow("LOL", new QLineEdit());
> formLayout->addRow("WAT", new QLineEdit());
> formLayout->addRow("WOW", new QLineEdit());
> vBoxLayout->addLayout(formLayout);
> setLayout(vBoxLayout);
> }
>
> And this is (not the example but the code isn't that much different)
> what I get when I resize the QMainWindow. On the screenshot you can also
> see what is happening when I add a widget into either one of both
> layouts (existings widgets become smaller since the layout is not resized).
>
> http://www.ixamaxi.be/images/problem-layout.png

I can see on this screenshot that you do this onn your layouts:
layout->setSizeConstraint(QLayout:SetNoConstraint)

I think you shouldn't do this, let the layout manage sizes for you.

My 2 cents.
Chris

>
> Could someone explain me what is happening ?
>
> Thank you very much.
>
> Best regards
> Maximilien Renard
> ULB - MA1 Ingénieur Civil Biomédical
> maximilien.renard at ulb.ac.be <mailto:maximilien.renard at ulb.ac.be>
> +32 476 63 68 92
>
>
>
> _______________________________________________
> 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