1

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

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
praveen
  • 67
  • 5
  • What is your ultimate goal? Why do you want to capture when that button is pressed? – eyllanesc Nov 02 '21 at 17:25
  • Hi, Based on Hide key event, I want to popup a message – praveen Nov 03 '21 at 04:38
  • @eyllanesc I'm looking for an answer to the original question. I'd like to be able to switch from the virtual keyboard to an external keyboard or vice versa depending on a button click. I'd like to get the hidekeyboardkey clicked event to handle it. Is this possible? – slayer Sep 14 '22 at 20:25

1 Answers1

2

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")
        }
    }
}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241