Qt World Summit: Register Today!

[SOLVED] problem with QDockWidget position

  • Hi All,
    I have used QDockWidget to show my dialog in right hand side of the main window and also it should be expandable as well.

    . I tried lot of functions to show this, but its keep on showing the defualt position & size.. here is my code.


    void MainWindow::createDockWindows()

         ///////////////////Dialog dock//////////////
      QDockWidget *dlgDock = new QDockWidget(tr("Test Dialog"),this);
        dlgDock->setWidget(new testDlg(this));
       // dlgDock->setMinimumWidth(1);
        dlgDock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
            addDockWidget(Qt::RightDockWidgetArea, dlgDock);


    please thro some light on this..

  • Have a look at "allowedAreas"

    There is also a good example that shows everything you need to know about QDockWidget.

  • Thanks for your reply.

    As per the function AllowedAreas- which is allowing us to specifiy where we have to show our DockWidget in our main window either right ,left ,top or bottom ...

    But my requirement is to show the Dockwidget as half of the main window..
    and also it should be expandable as well, So i used the Qt:Expanding attributes for the same.

    Please refer the below picture, here the Ist part is the main Window & second part is the DockWidget
    & i need to show this, while opening my application itself..

    | | |
    | | |
    | | |
    | | |
    | | |
    | | |
    | | |
    | | |
    | | |


  • "from the docs :":http://doc.qt.nokia.com/4.7/qdockwidget.html#appearance

    bq. Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on the QDockWidget itself, because they change depending on whether it is docked; a docked QDockWidget has no frame and a smaller title bar.

  • Thanks Eddy...

  • You're welcome.

    Could you please add [Solved] in front of your title?

  • i updated...Thank you so much..

Log in to reply