PDA

View Full Version : numeric value problem...



ocascante
29th June 2007, 18:10
Hi,

I have qlineedit field "le03" and i need to show the result of :

QString::number(le01->text().toDouble() / 2) where le01 = "99999999.00"
in that field.

The problem is the operation shows a scientific notation value. I need to show the result like this: 49999999.05

Thanks

Michiel
29th June 2007, 18:37
Try this: QString::number(le01->text().toDouble() / 2, 'f')

And try to look it up in the Qt docs next time.

ocascante
29th June 2007, 18:46
Thanks for your help and your time!!!

PD/ About qt docs, i did it and i didn't find the answer..... that's is the post reason!!

sunil.thaha
2nd July 2007, 18:25
Then look closer ;)


QString QString::number ( double n, char format = 'g', int precision = 6 ) [static]

This is an overloaded member function, provided for convenience.
Returns a string equivalent of the number n, formatted according to the specified format and precision. The format can be 'f', 'F', 'e', 'E', 'g' or 'G' (see the arg (http://doc.trolltech.com/4.3/qstring.html#arg)() function documentation for an explanation of the formats).
Unlike QLocale::toString (http://doc.trolltech.com/4.3/qlocale.html#toString)(), this function does not honor the user's locale settings.
See also setNum (http://doc.trolltech.com/4.3/qstring.html#setNum)() and QLocale::toString (http://doc.trolltech.com/4.3/qlocale.html#toString)().