[PyQt] Signal this way

pantheon animator333 at yahoo.com
Tue Sep 29 02:47:11 BST 2009


Hi,

I am creating <QAction> in a loop and adding it to menu.
       

action = QtGui.QAction(QtGui.QIcon(iconFile), fileName, menu)
menu.addAction(action)


I need to connect this action to a python function in such a way that I
should get <text> of QAction or instance of QAction object itself.
Python function:

If action name is required

def contextMenuAction(self, actionName):
        print actionName


If action object is required

def contextMenuAction(self, actionObject):
        myData = actionObject.data()



How do I setup action and slot? Logically it would be like this:

self.connect(action, QtCore.SIGNAL("triggered()"), self,
QtCore.SLOT("contextMenuAction(str)"), fileName)
self.connect(action, QtCore.SIGNAL("triggered()"), self,
QtCore.SLOT("contextMenuAction(object)"), action)


Cheers

Prashant

Python 2.5.2
PyQt-Py2.5-gpl-4.4.3-1
Win XP, 32 Bit 
-- 
View this message in context: http://www.nabble.com/Signal-this-way-tp25655744p25655744.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list