0

I have a Qt application with some QDockWidgets, which can be docked and undocked with these features:

  • DockWidgetFloatable
  • DockWidgetMovable
  • DockWidgetVerticalTitleBar
  • DockWidgetClosable

I would like to use the window layout manager of Windows (like using a split screen of the docked widgets and the main application). But it's not possible now because the docked widgets are still child windows of the main application.

Is there a flag I can set to make them as separate windows?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
locke14
  • 1,335
  • 3
  • 15
  • 36
  • Okay so my question to you is why are you creating Dockable windows if that is not what you want -- if what you are wanting are stand alone windows than create QWidgets or some other type of Window Object for these tertiary windows – Dennis Jensen Oct 21 '19 at 19:47

1 Answers1

1

flags Qt::WindowFlagsflags Qt::WindowFlags - Qt::Window

Indicates that the widget is a window, usually with a window system frame and a title bar, irrespective of whether the widget has a parent or not. Note that it is not possible to unset this flag if the widget does not have a parent.

import sys
from PyQt5.QtCore    import *
from PyQt5.QtGui     import *
from PyQt5.QtWidgets import *

class Dockdemo(QMainWindow):
    def __init__(self, parent=None):
        super(Dockdemo, self).__init__(parent)

        self.setWindowTitle("Dock demo")
        self.setCentralWidget(QTextEdit())

        items      = QDockWidget("Dockable", self, flags=Qt.Window)  # flags=Qt.Window
#        items.setGeometry(650, 130, 300, 200)
        items.show()                                                 # +++

        listWidget = QListWidget()
        listWidget.addItem("item1")
        listWidget.addItem("item2")
        listWidget.addItem("item3")
        items.setWidget(listWidget)
        items.setFloating(False)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Dockdemo()
    ex.show()
    sys.exit(app.exec_())

enter image description here

Community
  • 1
  • 1
S. Nick
  • 12,879
  • 8
  • 25
  • 33