QGraphicsView::fitInView() does not work after expanding the view
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:
Code:
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?
Re: QGraphicsView::fitInView() does not work after expanding the view
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.