PDA

View Full Version : Fastest way to get width of rich text



jgrauman
22nd June 2010, 07:05
Hello,

I'd like to know what is the fastest (in running time, not coding time :) ) way to calculate the width of a piece of rich text? The text will have multiple fonts, so I can't just use QFontMetrics. I can set the text of a qtextdocument and get the width, I can try to use qtextlayout to get the width... Are there any other ways, anyone know what would be fastest?

Thanks.

Josh

Uwe
22nd June 2010, 08:25
Maybe it helps to have a look at the implementation of QwtRichTextEngine::textSize(): http://qwt.svn.sourceforge.net/viewvc/qwt/trunk/qwt/src/qwt_text_engine.cpp?revision=760&view=markup.

Uwe

franz
22nd June 2010, 23:07
Have a look at QFont and QFontMetrics. Especially the with() function in the latter will help.