How to find if QuickItem is topmost in QmlScene (z-order)?

321 views Asked by At

Currently I am developing in Qt / Qml, using QtQuick. I came to a point, where I need to find out, if an item of my scene is topmost. That is, I need to find if the item has the highest z-coordinate. I tried to build an algorithm, using childAt and mapToScene. It turned out, that this is horribly slow. Then I found out about itemAt(). Unfortunately, it is only available in GraphicScene, i.e. in the widget world.

Now my question: Is there an equivalent to itemAt() in the QmlSceneGraph? How can I find out, if an item is the topmost one? I do not even need the exact z-order, just to make sure, the item is displayed at top.

Thanks for your help.

Greetings from Germany

1

There are 1 answers

1
Meefte On

You can use Item::childAt(real x,real y) method

ApplicationWindow {
   id: root
   visible: true
   MouseArea {
      anchors.fill: parent
      onClicked: console.log(root.contentItem.childAt(mouse.x,mouse.y));
   }
}