I have a question about formatting a decimal number in a specific QString format. Basically, I have an input window in my program that can take any values. I want it to convert the value in this field to the "+05.30" format (depending on the value). The value will be limited to +/- 99.99.
Some examples include:
.2 β +00.02
-1.5 β -01.50
9.9 β +09.90
I think about using such a converter, but it will have some obvious problems (no pointers 0, no + sign).
QString temp = QString::number(ui.m_txtPreX1->text().toDouble(), 'f', 2);
This question had some similarities, but does not connect the front and rear gasket.
Convert int to QString with zero padding (leading zeros)
Any ideas on how to approach this problem? Your help is appreciated! Thanks!
c ++ qt string-formatting qstring
Imreg
source share