[Qt-interest] QFontMetrics boundingRect() vs width()

Josh jnfo-c at grauman.com
Fri Jun 18 03:27:32 CEST 2010


Hello all,

I'm working on some things with text layout and need to better understand 
how text is laid out. Obviously, QFontMetrics::boundingRect().width() is 
different than QFontMetrics::width(). What I'm trying to figure out is how 
they are related. For example, if I have a string, "This is a sentence" 
what causes the two values to be different? I thought it would be related 
to QFontMetrics::leftBearing() and rightBearing(), but I can't see any 
relationship there. Is there any way to figure out what the bounding rect 
will be based on the width? Any information about the relationship between 
these will be appreciated! Thanks!

Josh



More information about the Qt-interest-old mailing list