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

How is the Qt virtual keyboard initialized and how do I use it?



  • I am taking a look at the basic example for the Qt virtual keyboard. I can't seem to find any initialization for the keyboard or any place in the QML where it is being called. For instance, the only thing that happens in the QML when a user clicks the input box is that variable called focus is set too true:

    ... MouseArea  {
                id: content
                width: flickable.width
                height: textEditors.height + 24
    
                onClicked: focus = true
    
                Column {...
    

    does setting focus = true start up the keyboard and if so, how?


  • Moderators

    This is described in-depth in the documentation. In short & simplified: Qt has code which handles input (mouse, keyboard etc.) abstracted into platform plugin. QtVK plugs into that - so from the point of view of your application (and yourself) QtVK is treated 100% the same as if it was a real, physical keyboard.



  • @sierdzio Perhaps I wasn't clear about what I am asking. In QMl events usually have some kind of trigger, right? For instance, a push button will have an onClicked function. What function, in the QML code I posted, is causing the keyboard to become visible to the user? I think perhaps you thought I was asking more broadly about how the keyboard works, in reality, I just want to know how to hook it up, say for instance, to a button press:

    PushButton
             {
                text: "hello world"
                id: genericPushButton
                enabled: true
                onClicked: //What do I put here to enable the keyboard
                           //when a user clicks the push button?
             }
    

    or perhaps a Text Field or something of that nature.


  • Moderators

    @Circuits said in How is the Qt virtual keyboard initialized and how do I use it?:

    onClicked: //What do I put here to enable the keyboard
    //when a user clicks the push button?

    Qt.inputMethod.show()
    


  • @sierdzio This works, however; now I am left wondering how I specify the input method? For instance, activating the keyboard on a button press brings up the keyboard but it reports that:

    input method is not set
    

    when I press the button. How might I set that input method? I realize one way of doing it is by using TextInput{} or something along those lines instead of using a button. However, could I for instance alter the text property of the button itself with the keyboard?




Log in to reply