Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QGraphicsView: How to calculate the center?
xtingray last edited by xtingray
I am looking for the best way to calculate the current center of a QGraphicsView instance. The way to set the center is very easy using the centerOn() method, but if I want to get the opposite action (to get the QPoint center value), how should I do it?
Thank you for any hint :)
QRectF rect = view->scene()->sceneRect(); QPointF center = rect.center();
or do you mean the center on which the scene is currently scrolled?
QPointF sceneCenter = view->mapToScene( view->viewport()->rect().center() );