How to format a number into a const width string ?
For example, if n is 12345, it is formatted to "12345", if n is 123, it is formated to "00123", if n is 0, it is formatted to "00000".
thanks!
How to format a number into a const width string ?
For example, if n is 12345, it is formatted to "12345", if n is 123, it is formated to "00123", if n is 0, it is formatted to "00000".
thanks!
QString new( QString( "00000%1" ).arg( 1234 ) );
new = new.right( 5 );
Others may find more efficient solutions
Take a look at 'fieldWidth' and 'fillChar' parameters of QString::arg().
J-P Nurmi
Bookmarks