I am using QGraphicsView / QGraphicsScene to build in Qt. Scaling and fit work decently while I continue to draw big things. However, when the size of the rectangle rectangle decreases, the view does not. It just shows the same (or a large area).
Before rearranging the smaller scene in the view, I invoke the following commands:
mpScene->clear(); mpScene->setSceneRect(QRectF()); mpView->setSceneRect(QRectF()); mpView->resetMatrix(); mpView->fitInView(this->sceneRect(),Qt::KeepAspectRatio);
Alas, the canvas shown by the view continues to grow. What am I missing?
The scene and presentation are configured as follows (for completeness only):
mpView->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); mpView->setCacheMode(QGraphicsView::CacheBackground); mpView->setScene(mpScene); mpView->setWindowFlags(Qt::FramelessWindowHint); mpView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); mpView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); mpView->setFrameStyle(QFrame::NoFrame); mpView->setAutoFillBackground(false); mpView->setAttribute(Qt::WA_OpaquePaintEvent, true); mpView->setAttribute(Qt::WA_NoSystemBackground, true);
Note: Qt4.8 Version
source share