PDA

View Full Version : How to realiably create the boundingRect()



zarkzervo
19th February 2009, 10:38
Hi.

I create the bounding rectangle as I update the position of an QGraphicsItem (inherited). To check if it is what I want, I paint the boundingRect() at the end of the object's paint(). This looks okay.

My problem is that I see inconsistency on mousePressEvents() Sometimes it works just fine (checking along the border of the drawn boundingRect()) Sometimes it doesn't work at all. I suspect that some transformation or rotation has "warped" my bounding rectangle as the Scene sees it, but I'm not too knowledgable when it comes to transformation matrixes and scene/screen/object coordinates. How can I control that the boundingRect is the same as the mouse pointer sees it and the object sees it?

zarkzervo
19th February 2009, 13:00
"Solution":

There was a problem in defining the rectangle returned from boundingRect().

I had defined it as a point to point rectangle but had not taken into account that upper left must indeed be upper left. And after some transformations of the graphics view, upper left was anything _but_ upper left from my point of view.

The system only recognized as within the bounding box where the two rectangles would overlap.

The biggest problem was that when I tried actually drawing the returned boundingRect(), it looked perfectly all right.

Time for a break!