点击QSystemTrayIcon上的+ shift

时间:2013-07-05 12:14:38

标签: python qt pyqt pyside qt4.8

如何在click处理⇧shift(或⌘命令⌥选项)+ 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

1 个答案:

答案 0 :(得分:0)

您需要使用例如测试特定修改器的标记。 app.keyboardModifiers() & Qt.ShiftModifier