QGraphicsView: How to calculate the center?
Solved
General and Desktop
-
Hi,
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() );