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. How can I send keyevent into a qml textedit?
Forum Updated to NodeBB v4.3 + New Features

How can I send keyevent into a qml textedit?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 5.3k 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,

    For qtextedit, i can use coreapplication.sendevent(qtextedit, keyevent) to send in the specific keyevent.

    However for qml textedit, how can i do the same thing?

    Thanks!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      manishsharma
      wrote on last edited by
      #2

      sendEvent function requires reciever to be a QObject and textEdit item inherits QObject so you can still send event to textEdit. only thing you need to do is get access to textEdit from a c++ code and send events from there to textedit. For getting access to qml items in C++ please check http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        ytbryan
        wrote on last edited by
        #3

        Am I able to pass the keyevent to a QDeclarativeView? I read it in Keyboard Focus in QML. But i'm not sure how to do so.

        Please advise. Thanks!!!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          manishsharma
          wrote on last edited by
          #4

          well if your textEdit is in focus and only then you want to send the events then you can send event directly to the QDeclarativeView itself, QDeclarativeView should take care of forwarding keyevent to textEdit.

          QCoreApplication::sendEvent(declarative_view, keyEvent);

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aabc
            wrote on last edited by
            #5

            I tried to send key event to TextInput with coreapplication.sendevent but it does not work.
            Anyone has a code sample ?

            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