Hi,
i try to rotate a QRectF like this:
Qt Code:
painter.rotate(270);To copy to clipboard, switch view to plain text mode
but that code don't working. I would be rotate the QRectF at the QRectF center. How can i do that?
Hi,
i try to rotate a QRectF like this:
Qt Code:
painter.rotate(270);To copy to clipboard, switch view to plain text mode
but that code don't working. I would be rotate the QRectF at the QRectF center. How can i do that?
have a look at QMatrix and QTransform. (->translate)
Now i have try to rotate the QRectF like this:
Qt Code:
QTransform transform; transform.rotate(270,Qt::XAxis); transform.translate(rect.width(), rect.height()); painter.drawText( transformed, "Hello World", textOption );To copy to clipboard, switch view to plain text mode
but rotating with QTransform don't working too. What am i doing wrong?
you need to use translate() to put the rotation center inside your rect's center and then use QRect(-50,-10,100,20)
QRectF(-50,-10,100,20) center the rect and QTransform::translate ( qreal dx, qreal dy ) is the x and y axis to paint the rect? My rec is not rotated and paint on the given x-coordinate and y-coordinate. What am I doing wrong again?
It's not necessary to use QMatrix and QTransform to rotate a QRectF. Important is to translate the painter before rotate and center the rect like the following example:
Qt Code:
painter.translate(50, 50); painter.rotate(270); painter.drawText( rect, "Hello World", textOption );To copy to clipboard, switch view to plain text mode
Thanks for your help!
Bookmarks