Can QPainter.drawText rotate text ?
Solved
General and Desktop
-
I'm exporting the output of my application to a svg file using QSvgGenerator and QPainter. It goes well for the lines and paths, but I also need to output rotated text and I didn't find anything that allow me do to that.
Here is what I managed to do...
For the text output my application uses QGraphicsSimpleTextItem and setRotation() on it, and painter.drawText(). Is it possible to create a svg file having text tags with rotation transform or do I need to do that by myself ? -
@TomZ Thank you, I follow the order you mentioned and it works fine.
if (doSVG) { painter.setFont(fNum); painter.setPen(pNum); painter.save(); painter.translate(c.toPointF()+ b.toPointF() +tit->pos()); painter.rotate(radToDeg(ra)); painter.drawText(- ti->boundingRect().width()/2, -2, QString::number(n)); painter.restore(); }
-
@TomZ Thank you, I follow the order you mentioned and it works fine.
if (doSVG) { painter.setFont(fNum); painter.setPen(pNum); painter.save(); painter.translate(c.toPointF()+ b.toPointF() +tit->pos()); painter.rotate(radToDeg(ra)); painter.drawText(- ti->boundingRect().width()/2, -2, QString::number(n)); painter.restore(); }
-