[PyQt] Error in Split Dockwidget
tabish-->
tabish_shaikh555 at yahoo.com
Mon Aug 17 10:12:06 BST 2009
i am splitting the dockwidget but it is not splitting exactly in Half when
splitting Horizontally,
Following is the complete code.
import os,sys
from PyQt4 import QtCore,QtGui
global createdDockList
createdDockList=[] #list of created dockwidget container
class QdDockWidget(QtGui.QDockWidget):
def __init__(self, title, parent=None):
self.dockNumber=len(createdDockList)
self.dockNumber=self.dockNumber+1
QtGui.QDockWidget.__init__(self, parent)
self.main_obj=QdMainWindow
main_obj=parent
self.setObjectName("dock_%s"%(self.dockNumber))
self.setAttribute(QtCore.Qt.WA_DeleteOnClose) # Close the
dockwidget when clicking on 'X' of the dockwidget
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
createdDockList.append(self.dockNumber)
#QtCore.QObject.connect(self,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.main_obj.rightclickaction)
class QdMainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setDockOptions(QtGui.QMainWindow.AllowNestedDocks |
QtGui.QMainWindow.AnimatedDocks | QtGui.QMainWindow.AllowTabbedDocks |
QtGui.QMainWindow.VerticalTabs)
self.resize(604, 414)
self.contextMenu()
self.makeDock()
def makeDock(self):
dock = QdDockWidget(self)
self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock)
QtCore.QObject.connect(dock,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.rightclickaction)
def rightclickaction(self):
"""
for search right click options
"""
self.firstDockWidget=self.sender()
pos=QtGui.QCursor.pos()
self.rightmenu.popup(pos)
def contextMenu(self):
"""
"""
self.firstDockWidget=self.sender()
self.rightmenu=QtGui.QMenu(self)
self.rightmenu.addAction("split
Horizontally",self.createHorizontalSplit)
self.rightmenu.addAction("split
Vertically",self.createVerticalSplit)
def createHorizontalSplit(self):
print "firstDockWidget",self.firstDockWidget.objectName()
secondDock= QdDockWidget( self)
QtCore.QObject.connect(secondDock,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.rightclickaction)
print "secondDock",secondDock.objectName()
self.splitDockWidget(self.firstDockWidget,secondDock,QtCore.Qt.Horizontal)
def createVerticalSplit(self):
print "firstDockWidget",self.firstDockWidget.objectName()
secondDock= QdDockWidget( self)
QtCore.QObject.connect(secondDock,QtCore.SIGNAL("customContextMenuRequested(QPoint)"),self.rightclickaction)
print "secondDock",secondDock.objectName()
self.splitDockWidget(self.firstDockWidget,secondDock,QtCore.Qt.Vertical)
if __name__ == "__main__":
app = QtGui.QApplication([])
window = QdMainWindow()
window.show()
app.exec_()
--
View this message in context: http://www.nabble.com/Error-in-Split-Dockwidget-tp25003517p25003517.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list