PDA

View Full Version : How to get size (length, width ....) of string or char



Krishnacins
20th March 2006, 10:20
Dear Sir,
i want to know the size (width & length or area) of string or char with all property like (bold, italic, underline, color, font & fontsize) are operating on it.

means string or char can be considered a picture. So how can colculate its size

Thanks & regards
Krishna

Xagen
20th March 2006, 10:55
Look at QFontMetrics:

QFontMetrics fm( font() );

int w = fm.width( edit->text() );
// returns width in pixels