PDA

View Full Version : QString:: Padding Zeros?



Harvey West
27th February 2007, 16:59
Want to take an interger and produce a zero padded string output.
Can this be done in Qt?

e.g.
int i = 5;
QString str = ( code ... );
qDebug() << str; // prints 0005


Cheers

jpn
27th February 2007, 17:20
Try with QString::arg() (http://doc.trolltech.com/4.2/qstring.html#arg-5). You may pass a custom field width and a filling character.

ToddAtWSU
27th February 2007, 18:25
Try QString::leftJustified or QString::rightJustified. This should work for you.