Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Keyevent from qml

Keyevent from qml

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 3.4k Views 1 Watching
  • 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.
  • Y Offline
    Y Offline
    ytbryan
    wrote on last edited by
    #1

    Hi all,

    I know that it's not ready for a qml to emit keyevent according to "this":https://bugreports.qt.nokia.com//browse/QTBUG-15496

    May I know what is the recommended way to create a virtual button that create a new character entry in a textedit qml?

    Thanks!
    /bryan

    1 Reply Last reply
    0
    • R Offline
      R Offline
      roopeshchander
      wrote on last edited by
      #2

      I don't know what the "recommended" way is, but I got it working by doing something like this:

      • Create a C++ class (say KeyEmitter) which has a slot called sendKeyEvent(key, text, modifiers, whatever) - the slot, er, sends a key event ("sendEvent":http://doc.qt.nokia.com/4.7/qcoreapplication.html#sendEvent)
      • Make an instance of KeyEmitter available in QML ("setContextProperty":http://doc.qt.nokia.com/4.7/qdeclarativecontext.html#setContextProperty)
      • When you want to emit a key (eg. in your virtualButton.onClicked)
        ** Make sure you've set the focus on the item you want to send the key events to
        ** Call the KeyEmitter object's sendKeyEvent from QML/js
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved