2012-04-09 12 views
3

Qtが新しく、ウィンドウの右側にドッキングするDockWidgetを作成しようとしています。ドックの幅の最大値と最小値を設定します(下のコードを参照)。ドックウィジェットはQt::LeftDockWidgetAreaが付加されている場合、これは動作しますが、それはQt::RightDockWidgetAreaで追加されたときに、ドックはこのように、ウィンドウの中央に出て「パディング」である:私はおそらくでドックをサイジングするわけではない The red area shows the dock widget boundary. 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(); 
} 

「正しい」方法はありますか?ドキュメントに記載されているように

答えて

3

注:中央ウィジェットせずにメインウィンドウの作成がサポートされていません。たとえそれが単なるプレースホルダであっても、セントラルウィジェットを持たなければなりません。

関連する問題