Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 5.1 Android program does not send keypresses

I am creating a program in Qt 5.1 and Qt Quick 2.0 for Android but my phone doesn't seem to send keypresses. The same code works when i run it on my desktop so the focus seems to be okay.

Both the Keys.onPressed and the Keys.onBackPressed don't work, the back key just closes the program. I am debugging on a Android 4.2 device via ADB.

Main.qml

Rectangle {
    id: container
    focus: true
    Keys.onPressed: {
        console.log(event.key)
        if (event.key === Qt.Key_Backspace) {
            if (rectangleDetails.visible === true) {
            console.log("Left key pressed")
            rectangleDetails.visible = false
            listViewIndex.visible = true
            event.accepted = true
            } else {
                Qt.quit()
            }
        }
    }
    Keys.onBackPressed: {
        console.log("Back key pressed")
        if (rectangleDetails.visible === true) {
            rectangleDetails.visible = false
            listViewIndex.visible = true
            event.accepted = true
        } else {
        Qt.quit()
    }
}

Thanks in advance

like image 790
TeVeVe Avatar asked Dec 10 '25 05:12

TeVeVe


1 Answers

Try Keys.onReleased. This should solve your issue. See here for more information http://qt-project.org/forums/viewthread/29366

like image 170
LangstoniusRex Avatar answered Dec 12 '25 18:12

LangstoniusRex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!