PDA

View Full Version : fit QGraphicscene to QGraphicsview



nataly
17th January 2010, 10:19
Hi,

I have a QGraphicsview object which have a QGraphicscene.
I implemented it this way:
m_view = new QGraphicsView(m_scene,this);
(m_scene is a QGraphicsScene).
How can i display the scene , that it will fit the view?


Thanks

aladagemre
17th January 2010, 16:05
I'm also a newbie but I just used the following code. It might be useless or redundant but you might give it a try:



self.mainView.setSceneRect(self.mainScene.sceneRec t())
self.mainView.fitInView(self.mainScene.sceneRect() ,Qt.KeepAspectRatio)

C++ conversion (I hope it's correct):


m_view = new QGraphicsView(m_scene,this);
m_view->setSceneRect(m_scene->sceneRect());
m_view->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);