Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to use the OS back button on QML Loader component change and on SwipeView move?
Forum Updated to NodeBB v4.3 + New Features

How to use the OS back button on QML Loader component change and on SwipeView move?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 366 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mbruelM Offline
    mbruelM Offline
    mbruel
    wrote on last edited by mbruel
    #1

    Hi,
    at least for Android, when there is a back button, I'd like it be usable in my App when the view change so when I load another Item in a Loader or when the user swipe in the SwipeView.
    Is there a way to achieve that?
    At the moment the back button would close my App, whatever I do inside.

    Edit: I've tried to intercept it in Keys.onRelease but it is not working. The app closes.

        focus: true
        Keys.onReleased: {
             console.log("Key pressed: "+event.key);
            if (event.key === Qt.Key_Back) {
                console.log("BACK");
            }
        }
    

    Edit2: I'm running on MIUI where I've changed the Back button to be a small swipe on the left part of the screen. How could I intercept that? sounds like its in Android level...

    J.HilkJ 1 Reply Last reply
    0
    • mbruelM mbruel

      Hi,
      at least for Android, when there is a back button, I'd like it be usable in my App when the view change so when I load another Item in a Loader or when the user swipe in the SwipeView.
      Is there a way to achieve that?
      At the moment the back button would close my App, whatever I do inside.

      Edit: I've tried to intercept it in Keys.onRelease but it is not working. The app closes.

          focus: true
          Keys.onReleased: {
               console.log("Key pressed: "+event.key);
              if (event.key === Qt.Key_Back) {
                  console.log("BACK");
              }
          }
      

      Edit2: I'm running on MIUI where I've changed the Back button to be a small swipe on the left part of the screen. How could I intercept that? sounds like its in Android level...

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @mbruel where in you code is this?
      it should be at the top most qml file(Window/ApplicationWindow)

      your code should work there. If not, you can also reacte to the on closing and set it to false, that at least will stop the app from closing

      
      onClosing: {
          close.accepted = false
      }
      
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • mbruelM Offline
        mbruelM Offline
        mbruel
        wrote on last edited by
        #3

        @J-Hilk I don't use an ApplicationWindow, just a simple Window. my onReleased code is there. it is not triggered by the swipe action to do an Android back event.

        the onClosing is working :)
        I guess I can implement a state machine to remember the previous view (either due to a change of source of my main Loader or the index of the active SwipeView)
        Cool, thanks ;)

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved