PDA

View Full Version : Qt layout issue



bunjee
15th August 2007, 12:01
Hey there,

I have an issue with the QVBoxLayout.

I'm dynamicaly changing widget inside the layout : removing one and inserting another.

- When the new widgets occupies more space : the layout stretches and everything works fine.

But,

- When the new widgets occupies less space than the previous one : the layout doesn't shrink and keep its dimension.

Any way to force the resize of the layout ?

marcel
15th August 2007, 12:14
Try calling invalidate after adding the widget,

Regards

bunjee
15th August 2007, 12:29
Thanks,

Here is my code for my "settable widget" :


//================================================== ===========================
//================================================== ===========================

void ZeSettableWidget::setWidget(QWidget & widget)
{
ClearWidget();

mWidget = &widget;

mLayout.addWidget(mWidget);
mWidget->show();

mLayout.invalidate();
}

Doesn't seem to work, the layout doesn't shrink back to the smaller widget size.

marcel
15th August 2007, 12:50
Yes, you are right, it will never work like this.
You have to recreate the layout each time.

I think there are a few similar threads/

Regards

bunjee
15th August 2007, 16:28
I'm not sure to know what I'm searching for.

jpn
15th August 2007, 17:05
layout->setSizeConstraint(QLayout::SetFixedSize);

bunjee
15th August 2007, 20:43
mLayout.setSizeConstraint(QLayout::SetFixedSize);

worked with me.

Thanks.