[Qt-interest] Qt-interest Digest, Vol 18, Issue 70
Ross Driedger
ross at earz.ca
Sat May 8 01:03:38 CEST 2010
On 7-May-10, at 7:17 AM, qt-interest-request at trolltech.com wrote:
> Message: 2
> Date: Fri, 7 May 2010 15:51:59 +0530
> From: amulya rattan <talk2amulya at gmail.com>
> Subject: [Qt-interest] QFontMetrics question
> To: "qt-interest at trolltech.com" <Qt-interest at trolltech.com>
> Message-ID:
> <y2g82d45b421005070321p8bd3c31dj511b4332cd2a75e8 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi there,
>
> A query regarding QFontMetrics and which api to use for calculating
> size of
> a QString. The size is then used to create an svg out of text string.
> However I am not sure whether to go with width() or boundingRect().
> In the
> attached example, I have used both functions, once with whole string
> and
> once finding whole width as sum of widths of characters in the
> string. Using
> width(), both times(just string and sum of chars in string), the
> result was
> same(206). However, using boundingRect(), the results are different:
>
> 1. with whole string : 206(similar to results with width())
> 2. as sum of char width in string : 150!
>
> Can someone tell me why such a difference is there and which api
> should i
> use if i want to create an svg out of this string?
> Appreciate any response.
In my work, I don't use svg, but I do have some precision work with
characters. boundingRect() is my tool of chose and it works well for
me.
"Two things are infinite: the universe and human stupidity; and I'm
not sure about the the universe."
Albert Einstein
Ross Driedger
ross (at ) earz (dot) ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100507/42ecadaa/attachment.html
More information about the Qt-interest-old
mailing list