Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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.



  • Remembert QT is QuickTime not Qt.



  • 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)!



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



  • 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);
    

    @



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


Log in to reply