PDA

View Full Version : QGraphicsScene with scaled item freezes application on click



FlashMuller
27th January 2011, 12:22
Hey Guys,
I've got a nice little application which computes location-based scientific results and shows them, "pre-rendered" as Image-Files on a QGraphicsScene / QGraphicsView setup. Just to give you an idea: there are about 6 QGraphicPixmapItems / a few QGraphicsPolygon / QGraphicsLineItems on the screen, all static. The performance is fine so far.
Additionally I give the user the opportunity to load own datasets into the scene (like a map or whatever, format can be bmp, png or jpeg). The size of the image doesn't matter, it is automatically being scaled to the extend of previous datasets (e.g. a digital elevation model). Before actually adding the image, all "white" parts of the image are filtered (transparent Black/White-Map) Now this works fine as well. But as soon as I click somewhere in the scene the whole application freezes for more than a minute, stuck in the static bool EqualRegion(...) loop of qregion.cpp. After it is done with that, the general performance of the Scene slows down.
Any thoughts or tips on that?
Thanks,
Daniel

JohannesMunk
27th January 2011, 12:36
Hi Daniel!

Is there maybe a problem with one of your boundingRect or shape methods? Put breakpoints in them and see if one is called repeatedly.

HIH

Joh

FlashMuller
31st January 2011, 13:51
Thanks,
first of all I realized that the bounding rect of the QGraphicsPixmapItem stays the same size, even if it has been scaled. I don't know if that's a problem as the boundingRect in that case is bigger than the Scene/View. The reason why my program is stuck is the function static bool EqualRegion(...) of qregion.cpp, but I can't really find the reason for this call, how to avoid it etc, but it seems to me that there is a strong relation between Image-Size and Scaling / Displaying-Performance if the Image is transparent, which is the case.
Daniel