3
我是Qt新手,我试图创建一个停靠在窗口右侧的DockWidget。我为码头设置了最大和最小宽度(如下面的代码所示)。这适用于码头窗口小部件添加Qt::LeftDockWidgetArea
,但是当它被添加Qt::RightDockWidgetArea
,该码头是“填充”出到窗口的中心,就像这样: QDockWidget大小错误,当停靠在主窗口的右侧
我可能不施胶在被告席正确的方法..这里是这个窗口的代码:
int main(int argv, char** args)
{
QApplication app(argv, args);
QMainWindow window;
QDesktopWidget* desktop = QApplication::desktop();
//Docks
QDockWidget* propertyDock = new QDockWidget("",&window);
QWidget* propertyDockContents = new QWidget;
//This sets the window in the center of the screen.
int wWidth = 800; int wHeight = 600;
window.setGeometry(QRect((desktop->width()-wWidth)/2 , (desktop->height()-wHeight)/2 ,wWidth,wHeight));
propertyDock->setAllowedAreas(Qt::RightDockWidgetArea);
propertyDockContents->setMaximumWidth(200);
propertyDockContents->setMinimumWidth(20);
propertyDock->setWidget(propertyDockContents);
window.addDockWidget(Qt::RightDockWidgetArea,propertyDock);
window.show();
return app.exec();
}
有没有一个“正确”的方式来做到这一点?