[Interest] QGraphicsView stays big
Till Oliver Knoll
till.oliver.knoll at gmail.com
Thu Jun 7 08:55:32 CEST 2012
2012/6/7 Waitman Gobble <uzimac at da3m0n8t3r.com>:
> ...
> When I load an image into QGraphicsScene and add the scene to QGraphicsView, the QGraphicsView expands to image size, but if I clear and load another image which is smaller, it stays the same size.
That is by design and documented:
http://qt-project.org/doc/qt-4.8/qgraphicsscene.html#sceneRect-prop
"...largest bounding rect of all items on the scene since the scene
was created (i.e., a rectangle that grows when items are added to or
moved in the scene, but never shrinks)."
Try setting it to a "null" QRectF after removing the previous and
loading the new image: to my understanding the next call to
sceneRect() should then re-calculate the bounding rectangle, which
should then be just as large as the new image item in the scene.
Cheers, Oliver
More information about the Interest
mailing list