私は Qt が初めてで、ウィンドウの右側にドッキングする DockWidget を作成しようとしています。ドックの最大幅と最小幅を設定します (以下のコードを参照)。これは、ドック ウィジェットが で追加されQt::LeftDockWidgetArea
た場合に機能しますが、 で追加された場合、Qt::RightDockWidgetArea
ドックは次のようにウィンドウの中央に「パディング」されます。
おそらく、ドックのサイズを正しく設定していません。このウィンドウのコードは次のとおりです。
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();
}
これを行う「正しい」方法はありますか?