[PyQt] Dockable QTabWidget
Massi
massi_srb at msn.com
Tue Jul 17 09:22:21 BST 2012
Hi everyone,
I’m trying to develop a dockable version of a QTabWidget, since I saw that pyqt does not support it natively. Up to now I tried to realize it using the QDockWidget class, here is some code which shows what I did:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class DockTabWidget(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(1000, 700)
self.setTabPosition(Qt.AllDockWidgetAreas, QTabWidget.North)
self.dock_list = []
def AddComponent(self, component, label) :
d = QDockWidget(self.tr(label), self)
d.setAllowedAreas(Qt.AllDockWidgetAreas)
d.setWidget(component)
self.dock_list.append(d)
self.addDockWidget(Qt.LeftDockWidgetArea, d, Qt.Horizontal)
if len(self.dock_list) > 1 :
index = len(self.dock_list)-1
self.tabifyDockWidget(self.dock_list[-2], self.dock_list[-1])
if not hasattr(self, "tab_bar") :
self.tab_bar = self.findChildren(QTabBar)[0]
self.tab_bar.setTabsClosable(True)
self.tab_bar.setMovable(True)
def Test(self, index) :
print index
if __name__ == "__main__" :
import sys
a = QApplication(sys.argv)
dia = DockTabWidget()
dia.AddComponent(QWidget(), "t1")
dia.AddComponent(QWidget(), "t2")
dia.AddComponent(QWidget(), "t3")
dia.show()
a.exec_()
My problem is that the tabs of QtabBar cannot be used to drag away the pages and I’m forced to use the title bar, which I would like to be removed. Can anyone point me out if there is any way to achieve these goals (drag ffrom tabs and remove title bar)? Alternatively, is there any other way to realize a dockable QTabWidget?
Thanks in advance for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120717/a7a95478/attachment.html>
More information about the PyQt
mailing list