View Full Version : QGraphicsView Current Center
arjunasd
16th August 2007, 01:50
Hi
I have a QGraphicsView that is showing a QGraphicsScene. When saving the view, I also want to save the current centerlocation on the view, so that I can make the view centerOn the same point.
Is there any way to find the current center?
Thanks
Arjun
arjunasd
16th August 2007, 05:33
Hi all
I figured it out.
QPointF center = mapToScene(viewport()->rect().center()) gives the current scene point that is in the center of the view's viewport.
Using centerOn(center) would do the trick.
MarkoSan
1st December 2007, 20:06
Are there any possibilites to move (0,0) scene coordinate to center of scene parent widget?
marcel
1st December 2007, 20:11
See QGraphicsView::translate(). You can use this to translate view (0,0) to parent widget's center.
stretchtiberius
8th November 2010, 20:49
In order to find the center of the view in scene coordinates, I had to do it in the following order:
mapToScene(viewport()->rect()).boundingRect().center()
mapToScene(viewport()->rect().center() produces incorrect results and for me were a little to the upper left.
Can anyone help me understand why they are different?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.