The correct version of QString::arg() was already stated in the second post of this thread.
A hint:
- fieldWidth = 5 (4 digits + decimal point)
- format = 'f'
- precision = 2 (number of digits after the decimal point)
- fillChar = '0'
The correct version of QString::arg() was already stated in the second post of this thread.
A hint:
- fieldWidth = 5 (4 digits + decimal point)
- format = 'f'
- precision = 2 (number of digits after the decimal point)
- fillChar = '0'
J-P Nurmi
ok, final one line solution is:
QString str= QString("%1").arg(data, 5, 'f',2, '0');
its working.
Rajesh Kumar Singh
Bangalore, India.
Qt Search
Must Watch:
See how we can connect digital world objects to our day to day life….
whats with QString().sprintf("%.2f");
jacel,
finally homework done.Homework: Reduce all of this to a single line of code.
QString str= QString("%1").arg(data, 5, 'f',2, '0');
Rajesh Kumar Singh
Bangalore, India.
Qt Search
Must Watch:
See how we can connect digital world objects to our day to day life….
"Warning: We do not recommend using QString::sprintf() in new Qt code. Instead, consider using QTextStream or QString::arg(), both of which support Unicode strings seamlessly and are type-safe."![]()
J-P Nurmi
I want to know which solution is accepted by maverick_pol...
Rajesh Kumar Singh
Bangalore, India.
Qt Search
Must Watch:
See how we can connect digital world objects to our day to day life….
Bookmarks