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. Define the tab position when tabifying a QDockWidget

Define the tab position when tabifying a QDockWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.6k 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.
  • l3u_L Offline
    l3u_L Offline
    l3u_
    wrote on last edited by l3u_
    #1

    Hi :-)

    When I tabify a QDockWidget, it's always added as the last tab. E. g. if I have dock1 and dock2, and I create a new QDockWidget, and tabify it via tabifyDockWidget(dock1, newDock), it appears right of dock2, not dock1.

    Is there a way to define where the tab should appear (I would suppose to see it next to the one it was tabified with)? Or is it possible to programmatically move the tab to where it should be (like it can be done via drag and drop)?

    Thanks for all help!
    Cheers, Tobias

    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 ?
      Can you provide a minimal compilable example that shows 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
      • l3u_L Offline
        l3u_L Offline
        l3u_
        wrote on last edited by l3u_
        #3

        Here's a minimalistic example:

        main.cpp:

        #include <QApplication>
        #include "MainWindow.h"
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
            MainWindow mainWindow;
            mainWindow.show();
            return app.exec();
        }
        

        MainWindow.h:

        #include <QMainWindow>
        
        class MainWindow : public QMainWindow
        {
            Q_OBJECT
        
        public:
            MainWindow();
        
        };
        

        MainWindow.cpp:

        #include "MainWindow.h"
        #include <QDockWidget>
        
        MainWindow::MainWindow()
        {
            QDockWidget *dock1 = new QDockWidget(tr("Dock 1"), this);
            dock1->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
            addDockWidget(Qt::TopDockWidgetArea, dock1);
        
            QDockWidget *dock2 = new QDockWidget(tr("Dock 2"), this);
            dock2->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
            addDockWidget(Qt::TopDockWidgetArea, dock2);
        
            tabifyDockWidget(dock1, dock2);
        
            QDockWidget *newDock = new QDockWidget(tr("New Dock"), this);
            newDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
            addDockWidget(Qt::TopDockWidgetArea, newDock);
        
            tabifyDockWidget(dock1, newDock);
        }
        

        First, dock1 and dock2 are added and tabified. As expected, the dock2 tab appears right of the dock1 tab. After tabifying the new newDock, the tab is added right of the dock2 tab, and not (as at least I would expect it) right of the dock it was tabified with (dock1).

        Happens at least since Qt 5.6, and also with Qt 5.12.4 that I'm currently using.

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

          I would remove the second call of addDockWidget.

          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
          • l3u_L Offline
            l3u_L Offline
            l3u_
            wrote on last edited by
            #5

            This leads to the very same result …

            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