PDA

View Full Version : Convert number



madawg
26th July 2018, 05:47
I used

QString::number(number, 'f', 2)
When I put 1.3, 1, 1.1111
the console show: 1.30 1.00, 1.11
BUT How to remove the last 0 number: 1.3, 1, 1.11

Ginsengelf
26th July 2018, 08:04
With format 'f' the last number (2 in your example) defines the number of digits after the decimal point.
See http://doc.qt.io/qt-5/qstring.html#argument-formats

Ginsengelf