PDA

View Full Version : int to QString with defined size



^NyAw^
9th February 2012, 13:40
Hi,

I'm not able to find the corresponding method of solving this.
I have a int value and I want to get a QString with the format "XXXX", so when the value is 5 I need to get "0005".

Thanks,

wysota
9th February 2012, 14:53
Have a look at QString::arg() variant taking fieldWidth and fillChar parameters.

myta212
10th February 2012, 04:44
Hi,
Thank to wysota.
THis is example how to convert int to QString with defined size


int i;
QString str;
i = 5;
str = QString("%1").arg(i, 5, 10, QChar(48));

Thank you