Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] String conversion
david.luggen last edited by
How can I convert an int with one or two digits into a String which has always two digits but if the int is negative the minus sign is in front of the two digits?
12 -> "12"
9 -> "09"
-12 -> "-12"
-9 -> "-09"
Is there a smart function which does this, or need I to use an if-statement which converts first the absolute value of the int into a string -9 -> "09" and if the value was negative it prepents the minus sign to the string?
lgeyer last edited by
mario last edited by
or maybe this: "http://doc.qt.nokia.com/latest/qstring.html#arg":QString::arg()
by specifying a fieldWith and fillChar