PDA

View Full Version : Add nulls to QString



Robix
23rd April 2016, 19:02
Hello.



QString result;
QString sub;
QString end = "\n";
for (int x = 0; x < 1000; x++)
{
sub = sub.setNum(x);
result = result + sub + end:
}


result is:
1
2
3
..
999


I need that result to be with nulls before, like:
001
002
...
099
...
999


How to to this ?

anda_skoa
23rd April 2016, 19:40
See QString::arg() or QString::sprintf().

Cheers,
_