Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to get position of QML Items in C++?
likewise last edited by
I would like to know what the x, y and width, height of each QML Item is, from C++. Would I need to inspect the QQuickItems or somehow introspect the render nodes? Is there an example or more info on how I can do this?
Background: We are rendering offscreen / headless. When we switched away from software rendered QWidget/QPainter to QtQuick 2 we lost the information about dirty regions. We need to get this back somehow, as we need this information later.
the easiest solution is probably to give your qml object an objectName and using findChild to search for the QObject.
and than simply read the property e.g:
int x = myObject->property("x").toInt();
Do you need it only for debugging?
Maybe GammaRay can help you.
likewise last edited by likewise
Thanks, both pointers are useful.
I need it at run-time. I need to find which changed areas got drawn by the GPU to optimize our GPU to remote screen updates. (i.e. I need the equivalant of QPainter dirty regions.)