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. QDockWidget does not stay on the right when QMainWindow resizes
Forum Updated to NodeBB v4.3 + New Features

QDockWidget does not stay on the right when QMainWindow resizes

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 883 Views 3 Watching
  • 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.
  • V Offline
    V Offline
    vitorg
    wrote on last edited by
    #1

    Hi all,

    I have a QMainWindow with several QDockWidget objects in it. One of them is supposed to have fixed sized and stay on the right, and when I launch the application this does happen. But when I resize the QMainWindow (or maximize it) there appears a space between this QDockWidget and the rightmost part of the QMainWindow. The same thing happens if I put the QDockWidget on the left.

    See this video to better understand what I mean:
    https://drive.google.com/open?id=1Ho42-zurEABTwSPETnxCtqdtynexaALg

    As you can see, after I make the QDockWidget float and then dock it back in the QMainWindow, it all works as I would like it to from the beginning.

    Any idea if this is a configuration I am missing somewhere? I guess the QDockWidget itself wouldn't be the problem but...

    Thank you and cheers,
    Vítor

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt are you using ?
      What exact OS ?
      Can you provide a minimal compilable example that reproduce that behaviour ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vitorg
        wrote on last edited by
        #3

        Hi SGaist,

        Thanks for your time.

        The OS is linux and if I do uname --all I get:

        Linux ws-vitor 4.18.0-20-generic #21~18.04.1-Ubuntu SMP Wed May 8 08:43:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
        

        I am running this under xubuntu.

        The Qt version is that of the system: 5.9.5

        I've indeed managed to put up an example where this happens. It follows our gui, but simpler with only two tabs and a "Status" that we want to have on the right.
        Here you go:

        #ifndef TESTGUI_H
        #define TESTGUI_H
        
        #include <QMainWindow>
        #include <QDockWidget>
        
        class TestGui : public QMainWindow {
        public:
            TestGui() {
                setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks);
        
                QDockWidget* dockwidget = new QDockWidget("Tab #1");
                dockwidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
                dockwidget->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
                dockwidget->setMinimumWidth(1000);
                addDockWidget(Qt::TopDockWidgetArea, dockwidget);
        
                QDockWidget* prevdockwidget = dockwidget;
                dockwidget = new QDockWidget("Tab #2", this);
                dockwidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
                dockwidget->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
                dockwidget->setMinimumWidth(1000);
                addDockWidget(Qt::TopDockWidgetArea, dockwidget);
                tabifyDockWidget(prevdockwidget, dockwidget);
        
                // Problematic component
                dockwidget = new QDockWidget(tr("Status"), this);
                dockwidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
                dockwidget->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
                dockwidget->setMinimumWidth(160);
                dockwidget->setMaximumWidth(160);
                dockwidget->setAllowedAreas(Qt::AllDockWidgetAreas);
                addDockWidget(Qt::RightDockWidgetArea, dockwidget);
        
                setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
                resize(1100, 700);
            }
            ~TestGui() = default;
        };
        
        #endif // TESTGUI_H
        

        If you maximize the window, the status stays basically in the middle instead of going all the way to the right.
        Thanks a lot again.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you mean it stays locked on the left side of the right dock panel ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply
          0
          • SGaistS SGaist

            Do you mean it stays locked on the left side of the right dock panel ?

            V Offline
            V Offline
            vitorg
            wrote on last edited by
            #5

            @SGaist said in QDockWidget does not stay on the right when QMainWindow resizes:

            u mean it stays locked o

            Not that it stays on the left: that's where I want to have it.

            The problem is that it doesn't maintain its size: it becomes very wide, instead of keeping the 160 I wanted. And if you un-dock it and dock it back in again it will now have the proper size. I want to happen default when I resize (maximize) the main window.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vitorg
              wrote on last edited by vitorg
              #6

              Anyone, any idea? It seems like a bug in qt. Is it maybe solved in 5.13? Or previous versions even?

              Thank you very much.

              Gojir4G 1 Reply Last reply
              0
              • V vitorg

                Anyone, any idea? It seems like a bug in qt. Is it maybe solved in 5.13? Or previous versions even?

                Thank you very much.

                Gojir4G Offline
                Gojir4G Offline
                Gojir4
                wrote on last edited by
                #7

                @vitorg Hi, It may be related to this bug : https://bugreports.qt.io/browse/QTBUG-65592
                See this post
                Workaround is only one line of code so you will quickly know if that's the issue or not.

                1 Reply Last reply
                3

                • Login

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