tags:

views:

31

answers:

1

How to anchor QGraphicsView to a special point on a scene?

I want a center of a view is anchored to the scene point (0,0).

But as said in docummentation:

If the whole scene is visible in the view, (i.e., there are no visible scroll bars,) the view's alignment will decide where the scene will be rendered in the view.

And if I set agnment to Qt::AlignCenter view becomes anchored to the scene center.

Is it possibe to do?

I need something like QGraphicsView::centerOn that always put the point in to the view center.

A: 

You can set the alignment property to achieve this.

Patrice Bernassola
With AlignmentCenter the whole scene will be centered in the view. But not some special point.
graphite
When you speak about special point, you are speaking about points of QGraphicsItem in the scene? As far as I am concerned it's not possible for the view to manage the objects inside the scene.
Patrice Bernassola
Try switching the scrollbars off using setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ) and the same for horizontal as well. If you still have problems, try making sure the scene is always bigger than the view area.
Simon Hibbs
"try making sure the scene is always bigger than the view area" I think that's impossible because you always can zoom out so that the scene will be smaller.
graphite