0

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

MattW
  • 461
  • 3
  • 10

1 Answers1

1

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));
   }
}
Meefte
  • 6,469
  • 1
  • 39
  • 42
  • As it says in the opening post, I already tried that. But its buggy (although we were able to fix that bug) and we have to loop through all hierarchies. Just wondering, if there is a native solution in Qt, to find the top item. – MattW Nov 15 '14 at 12:01