I have a scene that I want to show an overview on (=zoom out), keeping my current center position.
view.setTransformationAnchor(QGraphicsView.AnchorV iewCenter)
zoom = QTransform()
zoom.scale(zoom_out_factor)
view.setTransformation(zoom)
Now, this almost works. If my coordinates are large, all is well. The trouble starts if the viewport would have to show sub-zero coordinates to satisfy the transform. Instead of extending, it just clips the scene at 0, which in turn results in the whole scene drifting off-center.
Example: if I'm looking at QRect(100,100,40,40), after the transform I'll be looking at QRect(90,90,60,60), which is OK. However, If I start at QRect(0,0,40,40), the result is QRect(0,0,60,60) and not the desired QRect(-10,-10,60,60).
Is there any elegant way around this ? I'm using setSceneRect() or inserting dummy elements at extreme cordinates to avoid this clipping, but I keep thinking there must be a better way![]()
Bookmarks