PDA

View Full Version : QGraphicsView::fitInView() does not work after expanding the view



lain
11th July 2011, 12:54
Hi,
I made a main window which has four frames (QFrame) in the grid layout. The first frame has a QGraphicsView to show an image set to QGraphicsPixmapItem.
I tried to implement functionality to "maximize" the first frame by hiding other three frames:

frame2->hide();
frame3->hide();
frame4->hide();
view->fitInView(item, Qt::KeepAspectRatio);With the code above the first frame (and the view) is expanded but the size of the image remains unchanged.

Could someone please give me a few pointers?

d_stranz
11th July 2011, 20:39
What is "item"?

Typically, you use fitInView() in your QGraphicView's resizeEvent() handler, and you give it the scene()->sceneRect() for the first parameters.

Calling this from anywhere else will have a one-time effect, since it won't be called after a resize unless it is in the resizeEvent handler.