How can i create for "Ctrl+C" bindings for 2 objects: self.table, self.editor
I have:
shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.table, None, self.copyTable)
shortcut2 = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.editor, None, self.copyText)
This works, but is toogled. If i have focus on self.editor and for the first time i press "Ctrl+C it does self.copyTable, the second time is does self.copyText.
What am i doing wrong? :P
I did find a workaround where i create a QAction which checks which object has focus and triggers the wanted action. But i would rather have it per object.
Edit (a working example):
shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self, self.copytoclipbord)
shortcut.setContext(QtCore.Qt.WidgetShortcut)