PDA

View Full Version : No idea about QGraphicsView



Shawn
27th June 2007, 09:01
I used QGraphicsView to draw a diagram like below
this diagram is depending on an xml file
so, the height and the width can be variable acoording to the user
Now I can draw it using a given initial position like (300,300)
My problem is:
1.after I finished drawing this diagram, what should i do to make it in the central of the window, especially when the user change the size of the window?
2.is there any way I can change the size of the scene/view according to the size of the diagram? and this diagram is still in the central of the window?


Thank a lot for help!

xgoan
27th June 2007, 09:55
Don't give a size to the scene and use the QGraphicsView::centerOn(const QGraphicsItem * item) function

Shawn
27th June 2007, 10:02
thx a lot
I remove this

scene.setSceneRect (0,0,2000,1600);

and it works !:p