TeVeVe
TeVeVe

Reputation: 33

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

Upvotes: 3

Views: 1092

Answers (1)

LangstoniusRex
LangstoniusRex

Reputation: 81

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

Upvotes: 2

Related Questions