PDA

View Full Version : widget not resized within QDockWidget



pospiech
3rd December 2008, 17:46
I added a new QDockWidget as all the other ones I already have. However this time the Widget is not resized within the QDockWidget, as if it had not layout.

It is created with this code:


dockAppMessages = new QDockWidget(this);
dockAppMessages->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea | Qt::LeftDockWidgetArea);
widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
dockAppMessages->setWidget(widgetDockPhaseShapesImpl);
dockAppMessages->setWindowTitle("Application Messages");
addDockWidget(Qt::BottomDockWidgetArea , dockAppMessages);
menuView->addAction(dockAppMessages->toggleViewAction());


widgetDockErrorMessage, the widget displayed within QDockWidget has a Layout, set to Expanding.

The ui file is the following


void setupUi(QWidget *widgetDockErrorMessage)
{
if (widgetDockErrorMessage->objectName().isEmpty())
widgetDockErrorMessage->setObjectName(QString::fromUtf8("widgetDockErrorMessage"));
widgetDockErrorMessage->resize(499, 153);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(widgetDockErrorMessag e->sizePolicy().hasHeightForWidth());
widgetDockErrorMessage->setSizePolicy(sizePolicy);
gridLayout = new QGridLayout(widgetDockErrorMessage);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
ErrorList = new WidgetListStringStack(widgetDockErrorMessage);
ErrorList->setObjectName(QString::fromUtf8("ErrorList"));
sizePolicy.setHeightForWidth(ErrorList->sizePolicy().hasHeightForWidth());
ErrorList->setSizePolicy(sizePolicy);

gridLayout->addWidget(ErrorList, 0, 0, 1, 1);

horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

horizontalLayout->addItem(horizontalSpacer);

pushButtonClearList = new QPushButton(widgetDockErrorMessage);
pushButtonClearList->setObjectName(QString::fromUtf8("pushButtonClearList"));

horizontalLayout->addWidget(pushButtonClearList);


gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);


retranslateUi(widgetDockErrorMessage);

QMetaObject::connectSlotsByName(widgetDockErrorMes sage);
} // setupUi


Any ideas?

Matthias

pospiech
4th December 2008, 07:53
widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
dockAppMessages->setWidget(widgetDockPhaseShapesImpl);


The correct version of the above code is


widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
dockAppMessages->setWidget(widgetDockErrorMessageImpl);


which makes the problem disappear...

jpn
4th December 2008, 18:19
Using a little bit more distinct variable names would've made the error visible. I still had to stare a few seconds the see what's the actual difference in your solution... :)