[Qt-interest] How to catch key press/release first?

Chandru sekarwagmare at gmail.com
Fri May 15 13:09:01 CEST 2009


if your widget is textedit
   textEdit->installEventFilter( this );

bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev )
{

 if ( obj == textEdit ) {
            if ( ev->type() == QEvent::KeyPress ) {

              return TRUE;
 }
}


On Fri, May 15, 2009 at 4:28 PM, Martin Gebert
<martin.gebert at alpha-bit.de>wrote:

> Hi!
>
> I'm currently exploring possibilities to catch key press and release events
> for the cursor keys and handle them before any other widget gets the chance.
> For context: my app/dialog needs a special "move around" mode where cursor
> keys are for movement of some target only (down -> start, up -> stop), and
> if that mode is off they should be handled as usual, depending on the widget
> that has the focus.
> I tried QWidget::grabShortcut(), but that doesn't give me a distinction of
> key down/up. event() and keyPressEvent() are called too late, after the
> currently focused widget got its turn. Next I'm thinking about registering
> an event filter in the QAppliction object. Any tips how to implement this
> behaviour reliably, respectively where to override the default behaviour?
> Thanks!
>
> Martin
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
WAGMARE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090515/00e3f5d5/attachment.html 


More information about the Qt-interest-old mailing list