Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Regarding Z-order in QML
Forum Updated to NodeBB v4.3 + New Features

Regarding Z-order in QML

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 5 Posters 31.1k Views 1 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.
  • K Offline
    K Offline
    krishkn
    wrote on last edited by
    #1

    How would i increase the z-order of an image dynamically ? I tried by increasing z ,but didn't work . any other way of doing it so that i can manually control Z-order of two images when a state gets changed ?

    Thanks
    Krishkn

    Regards,
    Krishkn

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mutaphysis
      wrote on last edited by
      #2

      Are those two elements siblings? Could you post an excerpt of your qml code?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kxyu
        wrote on last edited by
        #3

        z works. in most of cases) so, the code

        1 Reply Last reply
        0
        • P Offline
          P Offline
          parancibia
          wrote on last edited by
          #4

          Z-order works for me, a simple sample

          @
          import Qt 4.7

          Item {
          width: 200
          height: 200

          Rectangle {
              id: red
              z: 1
              color: "red"
              width: 100; height: 100
          
              MouseArea {
                  anchors.fill: parent
                  onClicked: red.z = blue.z + 1
              }
          
          }
          
          Rectangle {
              id: blue
              color: "blue"
              x: 50; y: 50; width: 100; height: 100
          
              MouseArea {
                  anchors.fill: parent
                  onClicked: blue.z = red.z + 1
              }
          }
          

          }
          @

          pieterbekaertP 1 Reply Last reply
          0
          • P parancibia

            Z-order works for me, a simple sample

            @
            import Qt 4.7

            Item {
            width: 200
            height: 200

            Rectangle {
                id: red
                z: 1
                color: "red"
                width: 100; height: 100
            
                MouseArea {
                    anchors.fill: parent
                    onClicked: red.z = blue.z + 1
                }
            
            }
            
            Rectangle {
                id: blue
                color: "blue"
                x: 50; y: 50; width: 100; height: 100
            
                MouseArea {
                    anchors.fill: parent
                    onClicked: blue.z = red.z + 1
                }
            }
            

            }
            @

            pieterbekaertP Offline
            pieterbekaertP Offline
            pieterbekaert
            wrote on last edited by
            #5

            Old topic, but not answered...
            The z property of Item determines stacking order of sibling items, i.e. elements belonging to the same item.
            Hence you cannot use the z property to move a child of parent A on top of (a child of parent) B if B is on top of A. (Which is a pity/pain :-))

            https://doc.qt.io/qt-5/qml-qtquick-item.html#z-prop

            1 Reply Last reply
            2

            • Login

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