[PyQt] Move a QDockWidget between two QMainWindows

Magnus Benjes magnus.benjes at googlemail.com
Mon Jul 6 21:35:11 BST 2009


Hello,
is there a way to move a QDockWidget between two QMainWindows?

In the sample code I have two QLabels wrapped into two QDockwidgets and I want to be able to move them from one QMainWindow to the other QMainWindow. But it doesen't work. What is missing in the code?

Regards
Magnus 


import sys
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication, QMainWindow, QLabel, QDockWidget

app = QApplication(sys.argv)

mw1 = QMainWindow()
mw2 = QMainWindow()

l1 = QLabel("Label 1")
l2 = QLabel("Label 2")

dw1 = QDockWidget("l1")
dw1.setWidget(l1)
dw2 = QDockWidget("l2")
dw2.setWidget(l2)

mw1.addDockWidget(Qt.LeftDockWidgetArea, dw1)
mw1.addDockWidget(Qt.RightDockWidgetArea, dw2)

mw1.show()
mw2.show()

sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090706/c2e50719/attachment.html


More information about the PyQt mailing list