PDA

View Full Version : Painting a right-aligned text



curreli
29th July 2010, 15:04
Hello,

How can I paint a text such that it gets positioned on the left of the target QPoint.

Example:

some text|

(where | represents the QPoint)

I'm currently using drawText but I don't think it allows such positioning.

Thanks in advance!

Lykurg
29th July 2010, 15:30
I'm currently using drawText but I don't think it allows such positioning
It does.
void QPainter::drawText ( const QRectF & rectangle, int flags, const QString & text, QRectF * boundingRect = 0 )
Use Qt::AlignRight for flags and simply position rectangle according to your given QPoint.

curreli
29th July 2010, 16:49
Works fine, thanks a lot!