views:

134

answers:

2

Hi,

how to determine the number of character of particular font will fit to screen. how to implement it.

Thanks

+4  A: 

Have a look at QFontMetrics. Using this, you can determine, among other things, the width of a particular string:

QFontMetrics metrics(myFont);
int width = metrics.width(myString);

Is this what you want?

Note: It is not possible to find the number of characters of a particular font that will fit on the screen since not all fonts are monospace. So the number of characters will depend on the actual characters.

Job
Ya, thanks.. i will look into this. if i get any prob i will ask..thanks
Shadow
A: 

you can also use QFontMetrics::elidedText passing available space (remember to reduce it with margins/paddings. Then call length on result string

Kamil Klimek
ya, but elided text, we can use to display the big string in small region right..
Shadow