Home > Mobile >  How to capture Hide key event in Qt VirtualKeyboard
How to capture Hide key event in Qt VirtualKeyboard

Time:11-04

I am using Qt virtual Keypad in my project.

I am able to print key values (using event.key) in console log for all keys, except hide key event (which is marked as red color in attached image).

Can anyone please help me in capturing the hide key event in virtual keyboard.

Below is the sample code for capturing key events

TextField{
    id:sampletextfield
    width: window.width/1.5
    height: parent.height*.5
    anchors.centerIn: parent
    font.bold: true
    font.pixelSize: parent.height*.2

    Keys.onReleased: {
        console.log("key event = "   event.key)
    }
}

Virtual Keyboard

CodePudding user response:

If you want to detect when the virtualkeyboard is hidden then you can use Qt.inputMethod:

Connections{
    target: Qt.inputMethod
    function onVisibleChanged(){
        if(Qt.inputMethod.visible){
           console.log("show")
        }
        else{
            console.log("hide")
        }
    }
}
  • Related