[Qt-interest] Cutting useless decimal places
mailinglists at bluespirit.la
mailinglists at bluespirit.la
Mon Oct 25 10:03:31 CEST 2010
Hello,
a very simple question: How can I create a QString from a
float/double, in format 'f' without giving a explicit number of decimal
places to the arg() arguments?
qDebug() << QString("Hello world: %1").arg( fNumber, 0, 'f' );
When setting fNumbers to '0.125' I want an output of '0.125'. But when
setting the fNumbers variable to '200', I don't want an output of
"200.000". I want also use the localized output - so I prefer
QString::arg() to QString::sprintf(). The use of precision==-1 is not
documented - at least not in qt 4.6 api-doc.
Thank in advance,
Charly
More information about the Qt-interest-old
mailing list