[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Dockable QTabWidget
From: "Massi" <massi_srb () msn ! com>
Date: 2012-07-17 8:22:21
Message-ID: DUB106-ds18FBE3C37744EBEDE94F0C9CDB0 () phx ! gbl
[Download RAW message or body]
Messaggio multiparte in formato MIME.
[Attachment #2 (multipart/alternative)]
Messaggio multiparte in formato MIME.
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!
[Attachment #5 (text/html)]
<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi everyone,</DIV>
<DIV> </DIV>
<DIV>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:</DIV>
<DIV> </DIV>
<DIV>from PyQt4.QtCore import *</DIV>
<DIV>from PyQt4.QtGui import *</DIV>
<DIV> </DIV>
<DIV>class DockTabWidget(QMainWindow):</DIV>
<DIV> def __init__(self):</DIV>
<DIV> QMainWindow.__init__(self)</DIV>
<DIV> self.resize(1000, 700)</DIV>
<DIV>
self.setTabPosition(Qt.AllDockWidgetAreas, QTabWidget.North)</DIV>
<DIV> self.dock_list = []</DIV>
<DIV> </DIV>
<DIV> def AddComponent(self, component, label) :</DIV>
<DIV> d = QDockWidget(self.tr(label),
self)</DIV>
<DIV>
d.setAllowedAreas(Qt.AllDockWidgetAreas)</DIV>
<DIV> d.setWidget(component)</DIV>
<DIV> self.dock_list.append(d)</DIV>
<DIV>
self.addDockWidget(Qt.LeftDockWidgetArea, d, Qt.Horizontal)</DIV>
<DIV> if len(self.dock_list) > 1
:</DIV>
<DIV> index =
len(self.dock_list)-1</DIV>
<DIV>
self.tabifyDockWidget(self.dock_list[-2], self.dock_list[-1])</DIV>
<DIV> if not
hasattr(self, "tab_bar") :</DIV>
<DIV>
self.tab_bar = self.findChildren(QTabBar)[0]</DIV>
<DIV>
self.tab_bar.setTabsClosable(True)</DIV>
<DIV>
self.tab_bar.setMovable(True)</DIV>
<DIV> </DIV>
<DIV> def Test(self, index) :</DIV>
<DIV> print index</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>if __name__ == "__main__" :</DIV>
<DIV> import sys</DIV>
<DIV> a = QApplication(sys.argv)</DIV>
<DIV> dia = DockTabWidget()</DIV>
<DIV> dia.AddComponent(QWidget(), "t1")</DIV>
<DIV> dia.AddComponent(QWidget(), "t2")</DIV>
<DIV> dia.AddComponent(QWidget(), "t3")</DIV>
<DIV> dia.show()</DIV>
<DIV> a.exec_()</DIV>
<DIV> </DIV>
<DIV>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? </DIV>
<DIV>Thanks in advance for your help!</DIV></DIV></DIV></BODY></HTML>
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic