qt - Android back button press doesn't trigger keys.onreleased qml -


i creating program in qt5.3 , qtquick2.1. trying capture button press on android in code using keys.onreleased. event not getting triggered. have set item focus true. still no success. here code sample

import qtquick 2.1 import qtquick.controls 1.2 import qtquick.controls.styles 1.2 import qtquick.layouts 1.1 import qtquick.window 2.1  rectangle {     id: main2     focus: true     width: screen.width     height: screen.height     keys.enabled: true     keys.priority: keys.beforeitem      property string load_page: ""     signal deskconnected()      loader{         id: pageloader         anchors.fill: parent         source: "qrc:/qml/resources/firstpage.qml"     }      ondeskconnected: {          pageloader.item.ondeskconnected()     }      function loadpatwin(){         pageloader.source = "qrc:/qml/resources/secondpage.qml";     }      keys.onreleased: {         console.log("back");         if (event.key === qt.key_back) {             event.accepted=true;         }     } } 

here loadpatwin function gets called on pressing button defined in other qml. , loads new qml. after when pressing button on android, app gets closed , doesn't print "back" in logs. suggestions doing wrong here?

thanks in advance.

in qt quick (qt5.1 , later) applicationwindow , window, both have closing signal emitted when user touches button in android. can implement onclosing handler , set close parameter false. here how it:

onclosing: {     close.accepted = false } 

by handler can manage button of android device. not need permission. example suppose have stackview manage gui. can write these lines of code, application behaves native android app:

onclosing: {         if(stack.depth > 1){             close.accepted = false             stack.pop();         }else{             return;         }     } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -