[PyQt] Disabling a key event
Gustavo A. Díaz
gustavo.diaz at gmail.com
Thu Oct 18 18:32:34 BST 2007
Thanks David!! I've forgot that method...
That worked very good.
Cheers.
2007/10/18, David Boddie <dboddie at trolltech.com>:
>
> On Thu Oct 18 03:22:32 BST 2007, Gustavo A. Díaz wrote:
>
> > 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?
> >
> > So, which action or code i should implement in place of "# DO Nothing.
> How?"
>
> If you want to stop key events from being passed on to other widgets, just
> accept the key event with event.accept().
>
> If you want to intercept events at a higher level, you'll need to start
> looking at event filters. The event model is described in detail in a Qt
> Quarterly article from 2004:
>
> http://doc.trolltech.com/qq/qq11-events.html
>
> On the other hand, if you just want to stop the window from being closed
> by
> the window system, you should reimplement closeEvent() in your main window
> and explicitly ignore the event passed to it:
>
> def closeEvent(self, event):
> event.ignore()
>
> Hope this helps,
>
> David
> --
> David Boddie
> Lead Technical Writer, Trolltech ASA
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
--
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071018/c8cbc759/attachment.html
More information about the PyQt
mailing list