Reputation: 5442
I am developing an app which will run firstly on Android. However, I have an issue with back button: each time it is tapped the application quits. I don't want this behaviour. I have checked a lot of approaches and I've tried to implement some code but nothing worked.
Here is my code:
Item {
id: student_home_page;
focus: true
// ///////////////////////////////////////////////////////////////
Keys.onReleased: {
console.log("TEST for Back ");
if (event.key == Qt.Key_Back) {
console.log("BAck Button HAndled");
event.accepted = true;
}
}
}
When I click back button after reaching this page, it does not print anything on console as it is not going inside
I only get this message on console of Qt Creator:
/uniActivity(15431): onStop
I/AndroidRuntime(15431): VM exiting with result code 0, cleanup skipped.
Any idea why it is not handling this key event or not any at all inside?
Upvotes: 2
Views: 2318
Reputation: 6414
You should handle the back button inside the StackView
itself, not a child page, see my answer here
Upvotes: 3
Reputation: 678
Maybe this could be useful for you. Try to override the activity onBackPressed() method:
@Override
public void onBackPressed() {
// Do something or call finish()
}
Upvotes: 0