Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-136717

Undocking a QDockWidget embedded inside an MdiSubWindow causes the QDockWidget to be unmovable and impossible to re-embed.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 6.9.0
    • Widgets: Main Window
    • None
    • Linux/Wayland

    Description

      Undocking a QDockWidget embedded inside an MdiSubWindow causes the QDockWidget to be unmovable, and subsequently impossible to re-embed (yet the button remains clickable).

      Reproduction

      #include <QApplication>
      #include <QMainWindow>
      #include <QMdiArea>
      #include <QMdiSubWindow>
      #include <QDockWidget>
      #include <QLabel>
      #include <QVBoxLayout>
      
      class MinimalMdiDockApp : public QMainWindow {
      public:
          MinimalMdiDockApp(QWidget *parent = nullptr) : QMainWindow(parent) {
              setWindowTitle("Minimal QMdiArea with QDockWidget Inside Sub-Window");
              resize(800, 600);
      
              // Create QMdiArea and set it as central widget
              QMdiArea *mdiArea = new QMdiArea(this);
              setCentralWidget(mdiArea);
      
              // Create QMdiSubWindow
              QMdiSubWindow *subWindow = new QMdiSubWindow;
              subWindow->setWindowTitle("Sub-Window with Dock Widget");
      
              // Create QDockWidget, parented to subWindow
              QDockWidget *dockWidget = new QDockWidget("Internal Dock", subWindow);
              dockWidget->setFeatures(
                  QDockWidget::DockWidgetClosable |
                  QDockWidget::DockWidgetMovable |
                  QDockWidget::DockWidgetFloatable
              );
      
              // Create content for the dock
              QLabel *dockContent = new QLabel("This is supposed to be a dock!");
              dockContent->setAlignment(Qt::AlignCenter);
              dockWidget->setWidget(dockContent);
      
              // Set QDockWidget directly as the widget of the subwindow
              subWindow->setWidget(dockWidget);
      
              // Add subwindow to mdi area
              mdiArea->addSubWindow(subWindow);
              subWindow->show();
          }
      };
      
      int main(int argc, char *argv[]) {
          QApplication app(argc, argv);
          MinimalMdiDockApp window;
          window.show();
          return app.exec();
      }
      
      
      Unable to find source-code formatter for language: pro. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      QT += widgets
      
      CONFIG += c++17 console
      CONFIG -= app_bundle  # Only needed on macOS to avoid .app packaging
      
      TARGET = MinimalMdiDockApp
      TEMPLATE = app
      
      SOURCES += main.cpp
      
      

      Attachments

        1. cpp_reproduction_sample.zip
          16 kB
          ROKE BEEDELL
        2. demonstration_screencast.webm
          1.10 MB
          ROKE BEEDELL
        3. pyqt6_reproduction_sample.py
          2 kB
          ROKE BEEDELL
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            axelspoerl Axel Spoerl
            beedellrokejulianlockhart ROKE BEEDELL
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes