Key Release Event

For get key events in event filter, this function must be called in class overrided event filter function before:

this->installEventFilter(this);

You can get key release event like this example:

bool ExampleApplication::eventFilter(QObject *object, QEvent *ev)
{
      if (ev->type() == QEvent::KeyRelease)
      {
           QKeyEvent* keyEvent = (QKeyEvent*)ev;

           if (keyEvent->key() == Qt::Key_A) 
           {
              lbl->setText("Key pressed : A");
           }
    }
    return false;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *