PDA

View Full Version : Number formatting for file name construction



philwinder
14th May 2008, 10:37
Hi there,
I am trying to format a file name as the following: 001test.csv, 002test.csv... 059test.csv.
I am currently using:

file.setFileName(folder + "/" + QString::number(someNumber) + file + ".csv");
But obviously that just sets the file name to 1test, 2test... 59test. Any thoughts?

Cheers,
Phil Winder
www.philwinder.com

mazurekwrc
14th May 2008, 10:57
try

QString( "%1" ).arg( someNumber, 3, 10, QChar( '0' ) )
instead of

QString::number(someNumber)