Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QQuickWindow : Center contentItem
dvdk last edited by
I am trying to fit the contentItem() in a QQuickWindow, like the fitInView function from QGraphicsView.
Scaling the contentItem()->childrenRect() to QQuickWindow::width() and height() is no problem, but centering the content in the QQuickWindow seems more difficult.
I fail to understand how to convert QQuickWindow coordinates to scene coordinates (mapToView equivalent)
Basically if I can determine the center of the QQuickWindow in scene coordinates, I can re-position the contentItem to be centered in the window.
What is the best way to center the contentItem in a QQuickWindow ?