我如何爲2個對象 「CTRL + C」 綁定創建一個快捷方式keybord:self.table,self.editor創建2個對象在PyQt的
我:
shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.table, None, self.copyTable)
shortcut2 = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.editor, None, self.copyText)
該作品,但是被迷惑了。如果我在self.editor並首次有重點我按下「Ctrl + C它self.copyTable,第二次是沒有self.copyText
我在做什麼錯:2 P
我發現在那裏我創建的QAction,檢查哪個對象具有焦點,並觸發所需動作的方法,但我寧願有它的每個對象
編輯(工作示例):
shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self, self.copytoclipbord)
shortcut.setContext(QtCore.Qt.WidgetShortcut)
你們這一個我不接受;)做到了現在:) – hugo24 2010-09-27 05:49:01
您可以通過'上下文= QtCore.Qt.WidgetShortcut ''QShortcut' init的參數 – Winand 2015-10-01 07:57:41