[PyQt] How to catch Shift+Ctrl+key in keyPressEvent?
linuxoidoz
linuxoidoz at yahoo.com.au
Mon Apr 12 06:39:11 BST 2010
I've reimplemented a QTextEdit's keyPressEvent:
[code]
class MyTextEdit(QTextEdit):
def __init__(self, *args):
QTextEdit.__init__(self, *args)
keyPressedSignal = pyqtSignal(int, bool, bool)
def keyPressEvent(self, event):
shift = False
ctrl = False
if (event.modifiers() & Qt.ShiftModifier):
shift = True
if (event.modifiers() & Qt.ControlModifier):
ctrl = True
self.keyPressedSignal.emit(event.key(), shift, ctrl)
[/code]
It catches either Shift or Ctrl but not both. Any idea how to catch both
Shift and Ctrl modifiers? Thank you.
PS. This code doesn't work only in Windows, in Linux it works fine, both
Shift and Ctrl are caught. Is this a bug or just the way the OSs work?
--
View this message in context: http://old.nabble.com/How-to-catch-Shift%2BCtrl%2Bkey-in-keyPressEvent--tp28214011p28214011.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list