[Qt-interest] How can I use QFontMetrics to measure strings which contains non-ASCII characters?

Kermit Mei kermit.mei at gmail.com
Wed Jan 19 02:27:25 CET 2011


Hello community!

    My program is asked to support several language such as English, Chinese
and so on.
I must measure some widget by its plainText. These text may consist of
different languages' characters.
Now, I use the code like this to measure:

    QFont  font;
    ... ... //set the font
    QFontMetrics fm(font);
    m_width = fm.width(plainText);

But I found that the result is not accurate. Is there any way to resolve it?

Thanks
-- 
B.R
Kermit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110119/61c8d7d8/attachment.html 


More information about the Qt-interest-old mailing list