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
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
def __init__(self, parent=None):
self.setLayout(self.layout)
self.initUI()
def initUI(self):
self.dockView.setWidget(self.grview)
self.viewAndTableLayout.addWidget(self.dockView)
self.dockTable.setWidget(self.table)
self.viewAndTableLayout.addWidget(self.dockTable)
self.layout.addLayout(self.viewAndTableLayout)
self.dockList.setWidget(self.list)
self.listAndTreeLayout.addWidget(self.dockList)
self.listAndTreeLayout.addWidget(self.dockTree)
self.layout.addLayout(self.listAndTreeLayout)
ex = Example()
ex.show()
ex.raise_()
sys.exit(app.exec_())
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class Example(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.initUI()
def initUI(self):
self.viewAndTableLayout = QHBoxLayout()
self.dockView = QDockWidget("View")
self.grview = QGraphicsView(self.dockView)
self.dockView.setWidget(self.grview)
self.viewAndTableLayout.addWidget(self.dockView)
self.dockTable = QDockWidget("Table")
self.table = QTableView()
self.dockTable.setWidget(self.table)
self.viewAndTableLayout.addWidget(self.dockTable)
self.layout.addLayout(self.viewAndTableLayout)
self.listAndTreeLayout = QHBoxLayout()
self.dockList = QDockWidget("List")
self.list = QListView()
self.dockList.setWidget(self.list)
self.listAndTreeLayout.addWidget(self.dockList)
self.dockTree = QDockWidget("Tree")
self.tree = QTreeView()
self.listAndTreeLayout.addWidget(self.dockTree)
self.layout.addLayout(self.listAndTreeLayout)
app = QApplication(sys.argv)
ex = Example()
ex.show()
ex.raise_()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks