[Interest] Event filter not working all the time (filter android default back button action)

Nuno Santos nunosantos at imaginando.pt
Tue May 10 16:42:47 CEST 2016


Hi,

I have the following event filter to filter the default back button Action on a Android app. I’m attaching this filter to the app QWindow.

It works, but not all the times! I was wondering why. Does anyone had the need to do something similar and can tell me why it is not working flawless all the time? 

I need to filter the default back button action in order to avoid the app crash. 
 
bool eventFilter(QObject *obj, QEvent *event)
{

    if (event->type()==QEvent::KeyPress)
    {
        QKeyEvent* key = static_cast<QKeyEvent*>(event);

        if (key->key()==Qt::Key_Back)
        {
            //qDebug() << "ignore default back button action on Android";
            event->accept();

            return true;
        }
    }

    return QObject::eventFilter(obj, event);
}

Nuno

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160510/d8656332/attachment.html>


More information about the Interest mailing list