PDA

View Full Version : maximum text width of interval



osiris81
20th January 2010, 13:19
Hi,

I need to find out the maximum text width of an interval, lets say [-100.50, 100.50] with precision of two.

I can find out the text width using the QFontMetrics, but that works only for a sample string. I'd have to convert every number in the interval to a string and calculate the width for it to get the maximum. Is there an easier way?

Thanks!

yogeshm02
20th January 2010, 13:54
What if you use [-888.88, 888.88] to calculate maximum string width (if I got you correctly)?

osiris81
20th January 2010, 14:37
why -888.88 and 888.88 ? it's not sure that the 8 is the "widest" character, it depends on the currently used font.