Intercept key on QLineEdit



  • hi!

    I need to intercept the F8 key when I'm on a QLineEdit.
    it's possible?



  • Use event filters for line edit.



  • @dheerendra

    ok, i did something like this, and seems to work:

    bool ForzaTestataContab::eventFilter(QObject *obj, QEvent *event) {
        QKeyEvent *key = static_cast<QKeyEvent *>(event);
        if (obj == editCondPag && event->type() == QEvent::KeyPress && key->key() == 16777271) {
            HelpWindow *help = new HelpWindow("get_cond_pag_all.txt");
            help->show();
        } else if (obj == editVett1 && event->type() == QEvent::KeyPress && key->key() == 16777271) {
            HelpWindow *help = new HelpWindow("get_vettori.txt");
            help->show();
        }
        return QObject::eventFilter(obj, event);
    }
    

    tks!!



  • My inputs. Don't compare key with big number. Check qt::key_f8. It is good practice.



  • @dheerendra said in Intercept key on QLineEdit:

    My inputs. Don't compare key with big number. Check qt::key_f8. It is good practice.

    ok, thanks a lot!!


Log in to reply