Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] problem with QDockWidget position
Forum Update on Monday, May 27th 2025

[SOLVED] problem with QDockWidget position

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 7.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    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->setBaseSize(500,500);
    
       // dlgDock->setMinimumWidth(1);
        //dlgDock->setMaximumWidth(1000);
        //dlgDock->setGeometry(200,200,500,600);
        dlgDock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        dlgDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
            addDockWidget(Qt::RightDockWidgetArea, dlgDock);
    

    }
    @

    please thro some light on this..

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Have a look at "allowedAreas"

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

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        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..
        @


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

        @

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          "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.

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • M Offline
            M Offline
            M_31
            wrote on last edited by
            #5

            Thanks Eddy...

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6

              You're welcome.

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

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • M Offline
                M Offline
                M_31
                wrote on last edited by
                #7

                i updated...Thank you so much..

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved