handle KeyEvent in C++



  • With a c++ class that has a slot

    void handleKeyEvent(QKeyEvent event);
    // or
    void handleKeyEvent(QKeySequence event);
    

    I can only use (inside qml) QKeySequence version of the slot given event from Keys.pressed. Sadly, this results in an empty sequence (QKeySequence::toString() gives an empty string).

    How one can handle those KeyEvents in a c++ class?



  • @BePie
    inherit QQuickview and override keypressEvent

    class MyQuickView : public QQuickView{
    public:
    void keyPressEvent(QKeyEvent * event){
    }
    }



  • thanks,

    I missed it because I usually used QQmlEngine or something alike and not a QQuickView.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.