PDA

View Full Version : Disappearing widgets in QVBoxLayout



torleifs
24th October 2007, 12:32
Hi.

I have subclassed QDockWidget and added some widgets to a vertical layoutmanager in it's constructor.
However, the widget of MyWidgetType is not visible.
If I don't add the QListWidget, I see the MyWidgetType widget just fine.

Could anybody give me any pointers as to what is going on here?

Torleif



this->setAllowedAreas(Qt::LeftDockWidgetArea);
mContextWidget = new QWidget(this);
mContextWidget->setMaximumSize(150, 250);
this->setWidget(mContextWidget);

mVerticalLayout = new QVBoxLayout();
mVerticalLayout->setMargin(9);
mContextWidget->setLayout(mVerticalLayout);

QLabel *myLabel = new QLabel(mContextWidget);
myLabel->setText("mylabel:");
mVerticalLayout->addWidget(myLabel);

mListWidget = new QListWidget(mContextWidget);
mVerticalLayout->addWidget(mListWidget);

MyOwnWidgetType *myWidget = new MyOwnWidgetType(mContextWidget);
mVerticalLayout->addWidget(myWidget);

torleifs
24th October 2007, 13:17
setSizePolicy() solved my problem.



myWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


Torleif