Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Android keys back.
Qt 6.12 LTS is out! See what's new in the release blog

Android keys back.

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.0k Views 2 Watching
  • 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.
  • T Offline
    T Offline
    Trikrista
    wrote on last edited by
    #1
    import QtQuick 2.4
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        id: rootItem
    
        Rectangle {
    
            anchors.fill: parent
            color: "lightgreen"
            focus: true
    
            Rectangle {
                id: rect
                focus: true
                width: parent.width * 2/3
                height: parent.height * 2/3
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
    
                color: "lightblue"
    
                Keys.onBackPressed: {
                    console.log("key back 2")
                }
            }
    
            Keys.onBackPressed: {
                console.log("key back 1")
            }
        }
    }
    

    How to get "key back 2"?

    I'm sorry for my bad English

    p3c0P 1 Reply Last reply
    0
    • T Trikrista
      import QtQuick 2.4
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          id: rootItem
      
          Rectangle {
      
              anchors.fill: parent
              color: "lightgreen"
              focus: true
      
              Rectangle {
                  id: rect
                  focus: true
                  width: parent.width * 2/3
                  height: parent.height * 2/3
                  anchors.horizontalCenter: parent.horizontalCenter
                  anchors.verticalCenter: parent.verticalCenter
      
                  color: "lightblue"
      
                  Keys.onBackPressed: {
                      console.log("key back 2")
                  }
              }
      
              Keys.onBackPressed: {
                  console.log("key back 1")
              }
          }
      }
      

      How to get "key back 2"?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Trikrista
      Try forwarding it. See forwardTo property.

      157

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trikrista
        wrote on last edited by
        #3

        forward work if item.focus = true

        And if I do not know what an item.focus = true?

        I'm sorry for my bad English

        p3c0P 1 Reply Last reply
        0
        • T Trikrista

          forward work if item.focus = true

          And if I do not know what an item.focus = true?

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Trikrista Keep focus on outer Rectangle. Add forwardTo.
          Then add into the list id of inner Rectangle.

          157

          1 Reply Last reply
          0

          • Login

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