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

      import sys
      from PyQt6.QtWidgets import (
          QApplication, QMainWindow, QDockWidget, QLabel, QMdiArea, QMdiSubWindow
      )
      from PyQt6.QtCore import Qt
      
      class MinimalMdiDockApp(QMainWindow):
          def __init__(self):
              super().__init__()
              self.setWindowTitle("Minimal QMdiArea with QDockWidget Inside Sub-Window")
              self.setGeometry(100, 100, 800, 600)
      
              self.mdi_area = QMdiArea()
              self.setCentralWidget(self.mdi_area)
      
              # Create a QMdiSubWindow
              sub_window = QMdiSubWindow()
              sub_window.setWindowTitle("Sub-Window with Dock Widget")
      
              # Create the QDockWidget
              dock_widget = QDockWidget("Internal Dock", sub_window) # Parent is sub_window, not QMainWindow
      
              # Set the required features for the QDockWidget
              dock_widget.setFeatures(
                  QDockWidget.DockWidgetFeature.DockWidgetClosable |
                  QDockWidget.DockWidgetFeature.DockWidgetMovable |
                  QDockWidget.DockWidgetFeature.DockWidgetFloatable
              )
      
              # Create content for the dock widget
              dock_content = QLabel("This is supposed to be a dock!")
              dock_content.setAlignment(Qt.AlignmentFlag.AlignCenter)
              dock_widget.setWidget(dock_content)
      
              # Set the QDockWidget directly as the content of the QMdiSubWindow
              # This is the key change.
              sub_window.setWidget(dock_widget) # Attempting to put QDockWidget directly
      
              self.mdi_area.addSubWindow(sub_window)
              sub_window.show()
      
      if __name__ == "__main__":
          app = QApplication(sys.argv)
          window = MinimalMdiDockApp()
          window.show()
          sys.exit(app.exec())
      

      Attachments

        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