QPainter::drawText bounding boxes for each character
Posted
by
satuon
on Stack Overflow
See other posts from Stack Overflow
or by satuon
Published on 2012-11-13T16:05:56Z
Indexed on
2012/11/13
17:01 UTC
Read the original article
Hit count: 624
I'm using QPainter to draw multiline text on QImage. However, I also need to display a colored rectangle around each character's bounding box.
So I need to know the bounding box that each character had when being drawn.
For example, for
painter.drawText(QRect(100, 100, 200, 200), Qt::TextWordWrap, "line\nline2", &r);
I would need to get 10 rectangles, taking into account newlines, word-wrap, tabs, etc.
For example, the rectangle of the second 'l'
would be below the rectangle of the first 'l'
, instead of being to the right of 'e'
, because of the newline.
© Stack Overflow or respective owner