[PyQt] Disabling a key event

Henrik Pauli henrik.pauli at gmail.com
Thu Oct 18 09:24:15 BST 2007


On Thursday 18 October 2007, Gustavo A. Díaz wrote:
> Hi!
>
> What i want to do this time, is to disable a key event in my app. For
> example i want to avoid closing the app by pressing ALT + F4:
>
> def keyPressEvent(self, event):
>         if event.key() == QtCore.Qt.Key_F4 and (event.modifiers() &
>         QtCore.Qt.AltModifier):
>             # DO Nothing. How?
                pass

I believe :)
The rest, you can let the source class handle them:

            else:
                 QMainWindow.keyPressEvent(self, event)

(or whatever the class is you're inheriting right now)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071018/532a59c1/attachment.bin


More information about the PyQt mailing list