PDA

View Full Version : Set size when insert a QWidget into a QGridLayout



Tondog
31st May 2010, 10:11
Hi togehter,
I've a QWidget which contained a QGroupBox.
The QGroupBox contained a vertical Layout.
Inside the QGroupBox, there's two other layouts. One is a QGridLayout.

I insert on runtime a QWidget into my QGridLayout. The problem is, that the size wouldn't re-adjust.
I want to have, that the layout will automatically set the size. Is that possible?


The code how I insert a QWidget into the QGridLayout:



QLineEdit* widget = new QLineEdit(this);
widget->setMinimumHeight(24);
widget->setMinimumWidth(50);
ui.gridLayout->addWidget(widget, cntRows, cntColumns, 1, 1);


Thanks for help

Lykurg
31st May 2010, 10:17
What size should be automatically set? Of the layout or the containing widget? If the later call adjustSize().

Tondog
31st May 2010, 10:23
Of the layout resp. of the window if the window is to small for all the widgets inside the QGridLayout

Tondog
4th June 2010, 06:35
I think it's a timing problem. If I make a singelshot, it works. Does anyone know the problem?


QTimer::singleShot(5, this, SLOT(setSize()));