Hi all. Reading the documentation for mapToItem/mapFromItem functions I've understand that it is possibile to translate a point to/from the coordinate system of the item itself. In particular, given the signature:
<itemName>.mapToItem(null, 0, 0) it is possibile to map the coordinate system origin of the item to the coordinate system of the top level window. This seems to work, as long as I don't use a Window, i.e. the following example gives different results (or correct ones which I cannot understand?): import QtQuick 2.4 import QtQuick.Window 2.2 Window { visible: true width: 600 height: 600 Rectangle { id: rec1 x: 200 y: 200 width: 200 height: 200 color: "green" opacity: 0.5 Component.onCompleted: { var coords = rec1.mapToItem(null, 0, 0) console.log("rec1: " + coords.x + "," + coords.y) } } Rectangle { id: rec2 anchors.centerIn: parent width: 200 height: 200 color: "blue" opacity: 0.5 Component.onCompleted: { var coords = rec2.mapToItem(null, 0, 0) console.log("rec2: " + coords.x + "," + coords.y) } } } The resulting coordinates are: qml: rec2: -100,-100 qml: rec1: 200,200 whereas I expected both rectangles to be at (200, 200). Window is not an Item, I know. Is this behaviour correct and I'm missing something trivial? Can the coordinates be traslated as expected? Thanks in advance, F.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest