How to get absolute Item position
Unsolved
QML and Qt Quick
-
Hi all.
There is a way to get the absolute (x,y) position of an Item in the screen?
There only one screen in the systemBest regards,
MZ -
Use Item.mapToGlobal(). This will return you global coordinate inside the window. Then you need to use Window's properties to get the window coordinates: https://doc.qt.io/qt-5/qml-qtquick-window-window.html#x-prop
-
@sierdzio I think
mapToGlobal
maps to screen rather than window coordinates, so the OP can use the value without further adjustment. I say this because it was confusing me last week - I was initially working on the assumption that it did map to window coordinates. Once I realised, I used the window's position to map the screen coordinates frommapToGlobal
to be relative to the main window.