Results 1 to 2 of 2

Thread: Number formatting for file name construction

  1. #1
    Join Date
    Apr 2008
    Posts
    73
    Thanks
    11
    Thanked 7 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Number formatting for file name construction

    Hi there,
    I am trying to format a file name as the following: 001test.csv, 002test.csv... 059test.csv.
    I am currently using:
    Qt Code:
    1. file.setFileName(folder + "/" + QString::number(someNumber) + file + ".csv");
    To copy to clipboard, switch view to plain text mode 
    But obviously that just sets the file name to 1test, 2test... 59test. Any thoughts?

    Cheers,
    Phil Winder
    www.philwinder.com

  2. #2
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Number formatting for file name construction

    try
    Qt Code:
    1. QString( "%1" ).arg( someNumber, 3, 10, QChar( '0' ) )
    To copy to clipboard, switch view to plain text mode 
    instead of
    Qt Code:
    1. QString::number(someNumber)
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to mazurekwrc for this useful post:

    philwinder (14th May 2008)

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.