当我想创建一个 QAction 时,我创建了这个对象。然后我将此 QAction 添加到菜单中:
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() 返回 True。控制台上没有打印任何内容以指示任何错误,并且不会引发异常。
我该如何调试呢?(或者,我做错了什么?)