PDA

View Full Version : Getting the bounding rectangle



ioannis
21st May 2009, 15:32
I have implemented the following code



QRectF rect(0, 0, height(), Margin);
painter->save();
painter->translate(50,0);
painter->rotate(90);
painter->drawText(rect,Qt::AlignCenter | Qt::AlignTop,str);
strBoundingRect = painter->boundingRect(rect,Qt::AlignCenter,str);
painter->restore();


However, using the above code return in strBoundingRect the initial bounding rectangle of the QString str and not the one that corresponds to the rotated and translated painter.

Can you give me an example on how can I obtain the bounding rectangle taking also into account both translation and rotation?

Thanks in advance...

wysota
22nd May 2009, 01:41
Rotate and translate the received bounding rect.


QRect r;
QTransform t;
t.rotate(...);
t.translate(...);
QRect transformed = t.mapRect(r);