[Interest] QGraphicsView stays big (solved)

Till Oliver Knoll till.oliver.knoll at gmail.com
Fri Jun 8 08:18:19 CEST 2012


Am 08.06.2012 um 04:19 schrieb "Waitman Gobble" <uzimac at da3m0n8t3r.com>:

> ...
>            gs->addPixmap(pm);
>            gs->setSceneRect(pm.rect()); //set the size using Andre's way.

Hmm, that's odd. While your code makes perfect sense from what I understand from the previously linked Qt docs is that it should also work with a "null" QRectF. And yes, I really meant "null" as in "QRectF::isNull() returns true" (the c'tor creates a "null" QRectF, just as was previously shown in André's code).

But apparently that doesn't work and hence seems to be a bug.

Imagine you would clear the scene and add /several/ new objects to it. Off course you could always calculate the bounding box of those objects yourself by iterating over them - but that is exactly the purpose of sceneRect(), if the current rectangle is a "null" one (at least according to the docs).


By the way: what do you do with your single pixmap in the graphics scene? Do you want to be able to zoom in? Otherwise why not use a simple QPainter to draw it onto some given widget?

Cheers,
  Oliver


More information about the Interest mailing list