Results 1 to 8 of 8

Thread: Creating a Tmporary file with random number ..

  1. #1
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Creating a Tmporary file with random number ..

    Hi,

    Actually I want to create a temporary file like temp.txt.<random number>,
    because temp.txt file is already exists in that directory.

    then I want to assign that temporary file to QFile,

    how can I do that ?

    Thanks for your replies.

    -npc

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a Tmporary file with random number ..

    Why don't you use QTemporaryFile ? http://doc.trolltech.com/4.1/qtemporaryfile.html

  3. #3
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a Tmporary file with random number ..

    Thaks for your reply,

    Sorry I forgot to tell my Qt version, It is Qt 3.3 I cant find any classes like that.

    -npc

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a Tmporary file with random number ..

    I think you can use QUuid for this.

  5. #5
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Creating a Tmporary file with random number ..

    Thanks munna,

    Is there any other way to do this apart from using UUID ?

    -

  6. #6
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a Tmporary file with random number ..

    hmmm....

    I was not able to find any other method using Qt 3. Some expert here might know a better way. Wait for their replies

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating a Tmporary file with random number ..

    You can create a "pseudorandom" filename based on current time and process id and then create a file with that name.

  8. #8
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Creating a Tmporary file with random number ..

    Thank you wysota,

    I used getpid() to get the process id, and used the same.

    -

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.