How to correctly use the virtual keyboard



  • I am trying to use the virtual keyboard in a qml based desktop application that may run in fullscreen or windowed mode.
    The documentation does not make it clear to me how I do this right.

    What I fiddled together now is:

    // imports
    
    ApplicationWindow  {
    
      // other components
    
      InputPanel {
        id: virtualKeyboard
        anchors.bottom: parent.bottom
        width: parent.width
        visible: InputContext.focus
        z: 10 
      }
    }
    

    In principle this behaves as I want it to. However the HideKeyboardKey does nothing.
    So is this the intended way to use these qml components or am I on the wrong track? How would I catch if the HideKeyboardKey is pressed?

    update
    I can catch key presses with

                InputContext.inputEngine.virtualKeyClicked.connect(function (key, text, modifiers) {
                  console.log('click ' + text)
                })
    

    but the HideKeyboardKey does not trigger this signal.



  • I went through the whole documentation again and in the only available example there is a comment

    /*  The visibility of the InputPanel can be bound to the Qt.inputMethod.visible property, ...
    

    So I tried that and it works.

        InputPanel {
            anchors.bottom: parent.bottom
            width: parent.width
            visible: Qt.inputMethod.visible
            z: 10
        }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.