[Qt-interest] Disable centering scene in QGraphicsView!
Sean Harmer
sean.harmer at maps-technology.com
Wed Jun 16 11:23:34 CEST 2010
Hi,
On Wednesday 16 June 2010 10:14:48 Jack Mack wrote:
> I use the QGraphicsScene to handle some QGraphicsPixmapItems. The scene is
> also visualized by a QGraphicsView.
>
> But the scene is always showed centered. I know this is the default
> settings. What I want sounds simple but I don't know how I can do that.
>
> When I insert two items to the scene and select one and moves it to the
> right border of the view (widget) then the other one is moving out of the
> left border. I think the problem is that the views rect is not actualized
> with the scene size. The scene is always centered to the (too small!)
> view.
>
> And how I can setup the view and scene that both coordinates origin (0/0)
> starts at the left above corner?
The problem sounds like you are not explicitly setting a scene rect on your
scene. So when you move your item(s) outside of the current scene rect, the
QGV framework is automatically calculating a new bounding scene rect for your
scene from the union of all the scene's item's bounding rects. See the docs
for QGraphicsScene::sceneRect for more details.
To stop this just explicitly set a scene rect using
QGraphicsView::setSceneRect().
Cheers,
Sean
More information about the Qt-interest-old
mailing list