PDA

View Full Version : QPainter - Retrieve drawText size



Raccoon29
30th April 2008, 11:43
Hi all,

QPainter provides the function
QPainter::drawText()
to draw a text in a given bounding rectangle.

Now, the situation is that I have to print a vertical list of texts and this function helps me to write a text without overriding the adjacents. It could so happen that a text requires more lines. Since I don't know how many lines it requires, is there a way to know how many of those lines it used or it is gonna to use (before drawing)?

I looked in the documentations but I found nothing usefull. Ideas?

aamer4yu
30th April 2008, 20:39
You could look at QFontMetrics.
May be it might help you

Raccoon29
2nd May 2008, 09:22
Yes, thank you for the hint, that's right what I needed :)