I am creating <QAction> in a loop and adding it to menu.
for fileName in fileNames:
action
= QtGui.
QAction(QtGui.
QIcon(iconFile
), fileName, menu
) menu.addAction(action)
for fileName in fileNames:
action = QtGui.QAction(QtGui.QIcon(iconFile), fileName, menu)
menu.addAction(action)
To copy to clipboard, switch view to plain text mode
I need to connect this action to a python function in such a way that I should get <text> of QAction <fileName> or instance of QAction object itself.
For example If action name is required
def contextMenuAction(self, actionName):
print actionName
def contextMenuAction(self, actionName):
print actionName
To copy to clipboard, switch view to plain text mode
If action object is required
def contextMenuAction(self, actionObject):
myData = actionObject.data()
def contextMenuAction(self, actionObject):
myData = actionObject.data()
To copy to clipboard, switch view to plain text mode
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)
self.connect(action, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("contextMenuAction(str)"), fileName)
self.connect(action, QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("contextMenuAction(object)"), action)
To copy to clipboard, switch view to plain text mode
Bookmarks