[Qt-interest] bounding box of rendered text
Alessandro Portale
Alessandro.Portale at trolltech.com
Tue Sep 22 05:28:35 CEST 2009
Hi,
in order to get the pixel size of strings, rendered in a particular
font, you can use QFontMetrics::size()
http://doc.qt.nokia.com/latest/qfontmetrics.html#size
If you do not specify a font when calling GLWidget::renderText(), you
get the right font metrics object from QApplication
http://doc.qt.nokia.com/latest/qapplication.html#fontMetrics
If you specify a font, you need to use your font as parameter for the
QFontMetrics constructor.
http://doc.qt.nokia.com/latest/qfontmetrics.html#QFontMetrics
Alessandro
Yifei Li schrieb:
> Hi all,
>
> I use GLWidget::renderText to display strings in a glwidget, and I want to get the size (in pixels) of a rendered string.
>
> How should I do that?
>
> Thanks
>
> Yifei
More information about the Qt-interest-old
mailing list