Reputation: 1375
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?
Upvotes: 1
Views: 1271
Reputation: 13651
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_())
Upvotes: 1