0

我该如何处理⇧ shift(或⌘ command⌥ option)+ clickon QSystemTrayIcon

我已经尝试过的:

app = MyApp(sys.argv)

class MyApp(QApplication):
    self.trayIcon = QSystemTrayIcon(self)
    self.trayIcon.activated.connect(self.trayIconActivated)
...
    def trayIconActivated(self):
        print "ACTIVATED", app.keyboardModifiers()
...

始终打印(无论是否按下按钮):

ACTIVATED <KeyboardModifiers object at 0x1002ad498>

def trayIconActivated(self):
    print app.keyboardModifiers() & QtCore.Qt.ShiftModifier
    print app.keyboardModifiers() & QtCore.Qt.ShiftModifier == QtCore.Qt.ShiftModifier

总是打印:

<KeyboardModifiers object at 0x1002ad4b0> 
False

版本:

PySide 1.1.2
Qt 4.8.4

4

1 回答 1

0

您需要使用例如测试特定修饰符的标志app.keyboardModifiers() & Qt.ShiftModifier

于 2013-07-05T12:21:37.917 回答