Tying PyQt4 QAction triggered() to local class callable doesn't seem to work. How to debug this?

Posted by Jon Watte on Stack Overflow See other posts from Stack Overflow or by Jon Watte
Published on 2010-04-21T01:28:15Z Indexed on 2010/04/21 1:33 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

I create this object when I want to create a QAction. I then add this QAction to a menu:

class ActionObject(object):
  def __init__(self, owner, command):
    action = QtGui.QAction(command.name, owner)
    self.action = action
    self.command = command
    action.setShortcut(command.shortcut)
    action.setStatusTip(command.name)
    QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), self.triggered)
  def triggered(self):
    print("got triggered " + self.command.id + " " + repr(checked))

Unfortunately, when the menu item is selected, the 'triggered' function is not called. QtCore.QObject.connect() returns True. Nothing is printed on the console to indicate that anything is wrong, and no exception is thrown.

How can I debug this? (or, what am I doing wrong?)

© Stack Overflow or respective owner

Related posts about pyqt4

Related posts about pyqt