Details
-
Task
-
Resolution: Cannot Reproduce
-
P3: Somewhat important
-
None
-
None
-
None
Description
These functions somewhat naturally fit together (a reasonable use case in a MouseArea might be to map the mouse location to another item, and then see if that item contains the mouse), but are not intuitive to use together. The following example demonstrates:
import QtQuick 2.0 Item { width: 400; height: 400 Rectangle { id: greenRect color: "green" width: 50; height: 50 anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { var pos = mapToItem(greenRect, mouse.x, mouse.y) console.log("pos", greenRect.contains(pos)) // always true, no matter where you click (no error generated) console.log("myPoint", greenRect.contains(Qt.point(pos.x, pos.y))) // true only when clicking within the green rectangle } } }