PDA

View Full Version : Why QPainter::rotate doesn't affect QPainter::boundingRect?



SkripT
29th April 2006, 01:06
Hi I want to know why QPainter::boundingRect returns the same QRect with or without rotation. I think that if some rotation is fixed, the bounding rect has to change too... What do you think?

jacek
30th April 2006, 12:28
Because when you rotate or translate the painter you change only the coordinate system it uses.

Suppose you have a class that receives a QPainter instance and draws some text on it (like QTextDocumentLayout or Q3CanvasItem). When you rotate the painter, everything that class paints will be rotated, but it doesn't have to know that you have rotated the painter --- it just draws using the current coordinate system.

Now if QPainter::boundingRect() would return a different rectangle depending on how much you have rotated the painter, it would brake everything --- suddenly the mentioned class would start drawing things differently if the painter was rotated and you wouldn't like that.

SkripT
30th April 2006, 19:01
Thanks jacek, thinking a little bit more in the problem I reached the same concclusion ;) So, how could I know the bounding rectangle of a rotated text? Exists an easy way to do it? or I have to applicate maths?

jacek
30th April 2006, 19:22
Try QMatrix.