[Qt-interest] Measuring the display width of text

Jason H scorp1us at yahoo.com
Sun Feb 28 04:39:20 CET 2010


What he means is Font, Size and Character  determine the width. Using those, make a hash table and use that to calculate the width.

Also, you might want to look at the hints provided to me as how to wrap a path as a painter path (gunnar to me) http://labs.trolltech.com/blogs/2010/01/18/qt-graphics-and-performance-fast-text/#comments




----- Original Message ----
From: Nikos Chantziaras <realnc at arcor.de>
To: qt-interest at trolltech.com
Sent: Sat, February 27, 2010 10:28:40 PM
Subject: Re: [Qt-interest] Measuring the display width of text

On 02/27/2010 02:55 AM, william.crocker at analog.com wrote:
>
>>
>> Instead, it seems I am forced to call QFontMetrics::size() repeatedly
>> while removing trailing characters from the string until enough
>> characters have been remove for the string to fit a given width. As
>> you can imagine, performance suffers.
>
> Binary search for the width and
> cache what you learn.

Thanks.  I'm using binary search now to determine the length, but can 
you explain a bit more about what you mean with caching?
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest



      




More information about the Qt-interest-old mailing list