OverviewV-Play 2 Support (Qt 5)[Apps] Custom back button behavior › Reply To: [Apps] Custom back button behavior

OverviewV-Play 2 Support (Qt 5)[Apps] Custom back button behavior › Reply To: [Apps] Custom back button behavior

V-Play Team

Hi Nathan!

Yes, the Android back button is automatically handled by some app components, which also includes popping pages from the NavigationStack.
Unfortunately, we currently do not yet provide a way to overwrite the default behavior in a convenient way. For that we want to have a well-structured component that handles the back-button and decides which implementation has priority if multiple handlers are defined.

This is already on our roadmap, and there will probably also be a way to define a custom handling within a Page as you suggested.

The inofficial way to add a custom handler to a Page looks like that at the moment:


import VPlayApps 1.0
import QtQuick 2.5

App {

  NavigationStack {
    backButtonEnabled: false // deactivate default behavior of navigation stack

    Page {
      title: "Custom BackButton"

      Text {
        id: textItem
        anchors.centerIn: parent
        text: "Press Back Button"

      // handle back button
      Connections {
        target: getApplication()
        onBackButtonPressedGlobally: {
          event.accepted = true

          // do sth here
          textItem.text = "Back Pressed"




Note: As this is just a connection to the back button press, other components (e.g. a Navigation which opens the first tab on a back press) might steal the back event from the page. So it might be a good idea to just stick with the default behavior until we have a better solution ready. 😉



  • This reply was modified 2 years, 5 months ago by  GT.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support