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. Dock widget resizing issue
Forum Updated to NodeBB v4.3 + New Features

Dock widget resizing issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdockwidget
7 Posts 2 Posters 4.5k Views 2 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.
  • Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on last edited by
    #1

    I have a couple of QDockWidgets in my QMainWindow. Each dock widget contains a different custom QWidget and has been added to the main window using QMainWindow::addDockWidget().

    The problem I am facing is that one of the docks can't be resized at all unless it is first undocked (made floating and then re-docked again). As soon as the dock widget is re-docked everything works as expected and the size of the dock can be changed however I need it.
    Does anyone have an idea what causes that behavior? The widget in the dock widget has the size policy set to expanding, not to fixed.
    Note: I can re-insert the floating dock exactly at the same place as it was before without touching the other docks and it will work. It really just boils down to un-docking and re-docking it to make it become resizable.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

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

      Hi,

      Can you show how you setup that dock and its widget ?

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

      Joel BodenmannJ 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you show how you setup that dock and its widget ?

        Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by Joel Bodenmann
        #3

        @SGaist Sure, here you go:
        I removed any non-contributing code such as the signal-slot connections.

        MainWindow::MainWindow()
        {
            // Dock options
            setDockOptions(AnimatedDocks | AllowNestedDocks | AllowTabbedDocks | GroupedDragging);
        
            // Terminal dock
            _terminal = new Terminal;
            QDockWidget* terminalDockWidget = new QDockWidget("Terminal", this);
            terminalDockWidget->setObjectName("Terminal Dock");
            terminalDockWidget->setWidget(_terminal);
            addDockWidget(Qt::BottomDockWidgetArea, terminalDockWidget);
        
            // Tasks list
            _tasksTreeView = new TasksView;
            _tasksTreeView->setModel(Preferences::instance().tasksManager());
            _tasksTreeView->setEnabled(false);
            QDockWidget* tasksDockWidget = new QDockWidget("Tasks", this);
            tasksDockWidget->setObjectName("Tasks Dock");
            tasksDockWidget->setWidget(_tasksTreeView);
            addDockWidget(Qt::BottomDockWidgetArea, tasksDockWidget);
        
            // Navigation dock
            _navigationTreeView = new WorkspaceNavigation;
            _navigationTreeView->setDragDropMode(QAbstractItemView::DragOnly);
            _navigationTreeView->setDragEnabled(true);
            QDockWidget* navigationDockWidget = new QDockWidget("Navigation", this);
            navigationDockWidget->setObjectName("Navigation Dock");
            navigationDockWidget->setWidget(_navigationTreeView);
            setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
            setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
            addDockWidget(Qt::LeftDockWidgetArea, navigationDockWidget);
         }
        
        void MainWindow::createDock(const QStringList& filePaths, const QString& viewerName)
        {
            QDockWidget* firstDock = nullptr;
            for (const QString& filePath : filePaths) {
                // Get the appropriate viewer
                Viewer* viewer = ...
        
                // Create a new dock
                QDockWidget* dock = new QDockWidget(viewer->toolWidgetName(), this);
                dock->setWidget(viewer->toolWidget());
                dock->setObjectName("Dock " + viewer->toolWidgetName());
                addDockWidget(Qt::RightDockWidgetArea, dock, Qt::Horizontal);
        
                // Tab them together
                if (firstDock) {
                    tabifyDockWidget(firstDock, dock);
                } else {
                    firstDock = dock;
                }
            }
        }
        

        It is the dock that I add in MainWindow::createDock() that shows the issue explained in my first post.
        It doesn't matter whether it creates just one dock (if the passed string list contains just one item) or if it creates multiple ones and tabs them together. In both cases I have to un-dock and re-dock the newly created dock before I can resize it using the mouse/splitters.

        Note: viewer->toolWidget() returns a regular QWidget that contains a layout with other QWidgets as layout items. Nothing special.

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

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

          The code looks good.

          One thing I would try is to remove the dock options and enable them one by one.

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

          Joel BodenmannJ 1 Reply Last reply
          0
          • SGaistS SGaist

            The code looks good.

            One thing I would try is to remove the dock options and enable them one by one.

            Joel BodenmannJ Offline
            Joel BodenmannJ Offline
            Joel Bodenmann
            wrote on last edited by
            #5

            I tried what you proposed but sadly without any luck. No matter which dock options I use - I can even leave them to the default ones - the issue remains: I can't resize the dock before I re-dock it.

            Any other ideas or suggestions?

            Industrial process automation software: https://simulton.com
            Embedded Graphics & GUI library: https://ugfx.io

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

              Which version of Qt are you using ? On which platform ?

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

              Joel BodenmannJ 1 Reply Last reply
              0
              • SGaistS SGaist

                Which version of Qt are you using ? On which platform ?

                Joel BodenmannJ Offline
                Joel BodenmannJ Offline
                Joel Bodenmann
                wrote on last edited by
                #7

                Qt 5.6.0 on Windows 64-Bit using MinGW 4.9.2 32-Bit

                Industrial process automation software: https://simulton.com
                Embedded Graphics & GUI library: https://ugfx.io

                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