Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved handle KeyEvent in C++

    QML and Qt Quick
    keyevent qkeyevent
    2
    3
    1233
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      BePie last edited by

      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?

      T 1 Reply Last reply Reply Quote 0
      • T
        Tirupathi Korla @BePie last edited by

        @BePie
        inherit QQuickview and override keypressEvent

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

        1 Reply Last reply Reply Quote 0
        • B
          BePie last edited by

          thanks,

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post