PDA

View Full Version : Creating dock widget as tab dynamically



vidyadhar
18th July 2009, 12:41
I am creating a dock widget dynamically at runtime.
problem i am facing is
1> i have to open a dock widget containing two tree widgets as a tab dynamically at runtime
2>also the tabs of dock widget should be placed above the dock widget and not below the widget .

please help me out as i have no one here to answer my question and on my own to complete the project.

Thanking you in advance.
here is my code..

def createdockProject(self):
self.dockUser = QtGui.QDockWidget(self.obj)
self.dockUser.setFeatures(QtGui.QDockWidget.DockWi dgetClosable|QtGui.QDockWidget.DockWidgetMovable)
#self.dockUser.setObjectName("dockUser_%s"%(self.title))
self.dockWidgetContents = QtGui.QWidget(self.dockUser)
self.dockWidgetContents.setObjectName("dockWidgetContents")
self.gridLayout = QtGui.QGridLayout(self.dockWidgetContents)
#self.gridLayout.setObjectName("gridLayout")
self.tree = QtGui.QTreeWidget(self.dockWidgetContents)
self.tree.setAlternatingRowColors(True)
self.tree.setHeaderLabel("")
self.tree.setHeaderHidden(True)
self.tree.setObjectName("tree1")
self.gridLayout.addWidget(self.tree,0,1,1,2)
self.tree1 = QtGui.QTreeWidget(self.dockWidgetContents)
self.tree1.setAlternatingRowColors(True)
self.tree1.setHeaderLabel("")
self.tree1.setHeaderHidden(True)
self.gridLayout.addWidget(self.tree1,0,0,1,1)
self.dockUser.setWidget(self.dockWidgetContents)
self.obj.addDockWidget(QtCore.Qt.BottomDockWidgetA rea,self.dockUser,QtCore.Qt.Horizontal)
self.firstDockWidget.setWidget(self.dockUser)

Lykurg
18th July 2009, 13:03
1> i have to open a dock widget containing two tree widgets as a tab dynamically at runtime

You could use a single dock widget with a QTabWidget inside. Or tab three dock widgets.


2>also the tabs of dock widget should be placed above the dock widget and not below the widget .

-> QTabWidget::TabPosition; QMainWindow::setTabPosition()