[PyQt] How to detect key combination?

Kelie kf9150 at gmail.com
Wed Jun 11 20:41:36 BST 2008


Hello,

I'm trying to detect the key combination of CTRL+DOWN for a QLineEdit widget.
This is what I've tried, but it doesn't work.

def keyPressEvent(self, event):
    if event.key() == QtCore.Qt.Key_Down and \
              int(event.modifiers() & QtCore.Qt.ControlModifier) ==
QtCore.Qt.ControlModifier
        print "CTRL key is down."

What did I miss? Thanks for your help!





More information about the PyQt mailing list