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. [solved] Can I fake a Keys.pressed signal?
Forum Updated to NodeBB v4.3 + New Features

[solved] Can I fake a Keys.pressed signal?

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 9.8k 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.
  • I Offline
    I Offline
    icetbr
    wrote on last edited by
    #1

    Hi, I'm making a virtual keyboard, so far only QML. It would be easier to integrate it into my application if I could make its signals the same as the real keyboard. Is this possible in QML? If on Qt, is it too hard?

    I want to be able to use a Keys.onPressed handler that deals with both the virtual and real keyboard, not create a different handler for each.

    Thanks

    edited: spell fixes.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      Remembert QT is QuickTime not Qt.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xsacha
        wrote on last edited by
        #3

        In QML you can define signals like this:
        @
        Rectangle {
        id: container
        signal clicked
        }@
        or use already defined ones of course

        You can then emit the signal using:
        @container.clicked();@

        So, if you have access to the keys, you can simply access .pressed() in your QML, for example. Or, if you don't have access, you can expose it with Qt (C++) and then use QML as per normal.

        For an example of a QML Software keyboard, have a look at "Colibri CLKeyboard":https://projects.forum.nokia.com/colibri/wiki/CLKeyboard component.
        !http://realnorth.net/share/ColibryKeyboardDemo.png(CLKeyboard Component)!

        • Sacha
        1 Reply Last reply
        0
        • I Offline
          I Offline
          icetbr
          wrote on last edited by
          #4

          What do you mean if I have access to the keys? It seems Qt/C++ is the way to go.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            blam
            wrote on last edited by
            #5

            If you mean you want to send key events from your virtual keyboard, which can then be received by Keys.onPressed, then that is quite easy to do from Qt/C++. For example,

            @
            QDeclarativeView view(QUrl::fromLocalFile("Window.qml"));

            QKeyEvent event(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
            view.scene()->sendEvent(view.rootObject(), &event);
            

            @

            1 Reply Last reply
            0
            • I Offline
              I Offline
              icetbr
              wrote on last edited by
              #6

              Thats more what I had in mind, thanks. Don't have the time to test it now though.

              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