Hi everybody,

hope someone can help me. I have a widget with a QGraphicsView, QTableView, QListView and a QTreeView. Each of them should be un/dockable. The undocking works, but how can I dock them back to the starting position? I don't want to drag them, I want to press a button and dock them back. Like how I undock them. At the beginning there is a bar with this undock-button. But after the undocking, this bar is gone.
I don't know what I need to do, to dock them back (with a button-press). Here is a bit code. I would be very thankful, if someone could help me out.

Kind regards,
Xinor

Qt Code:
  1. # -*- coding: utf-8 -*-
  2. from PyQt4.QtCore import *
  3. from PyQt4.QtGui import *
  4. import sys
  5.  
  6. class Example(QWidget):
  7. def __init__(self, parent=None):
  8. QWidget.__init__(self, parent)
  9. self.layout = QVBoxLayout()
  10. self.setLayout(self.layout)
  11. self.initUI()
  12.  
  13. def initUI(self):
  14. self.viewAndTableLayout = QHBoxLayout()
  15. self.dockView = QDockWidget("View")
  16. self.grview = QGraphicsView(self.dockView)
  17. self.dockView.setWidget(self.grview)
  18. self.viewAndTableLayout.addWidget(self.dockView)
  19.  
  20. self.dockTable = QDockWidget("Table")
  21. self.table = QTableView()
  22. self.dockTable.setWidget(self.table)
  23. self.viewAndTableLayout.addWidget(self.dockTable)
  24. self.layout.addLayout(self.viewAndTableLayout)
  25.  
  26.  
  27. self.listAndTreeLayout = QHBoxLayout()
  28. self.dockList = QDockWidget("List")
  29. self.list = QListView()
  30. self.dockList.setWidget(self.list)
  31. self.listAndTreeLayout.addWidget(self.dockList)
  32.  
  33. self.dockTree = QDockWidget("Tree")
  34. self.tree = QTreeView()
  35. self.listAndTreeLayout.addWidget(self.dockTree)
  36. self.layout.addLayout(self.listAndTreeLayout)
  37.  
  38. app = QApplication(sys.argv)
  39. ex = Example()
  40. ex.show()
  41. ex.raise_()
  42. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode