Results 1 to 4 of 4

Thread: dynamically create folders with QT

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default dynamically create folders with QT

    Hey you guys.

    Is it possible to create folder's during runtime (what I mean is that the program creates folders inside the current directory (so basically they are sub-folders) based on the current date).

    Let's say it's 22.10.2005 today. And the program would create a sub-folder with a name 22.10.2005 inside the current directory.

    Is that possible...

    Any hints are appreciated.

  2. #2
    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: dynamically create folders with QT

    Yes, of course it is possible. QDir::mkdir() or QDir::mkpath() are the way to go.

  3. #3
    Join Date
    Nov 2006
    Posts
    96

    Default Re: dynamically create folders with QT

    Hey. Thanks for your reply.

    Can you tell me one more thing. Why does this code not work:

    Qt Code:
    1. void MojeOkno::vpisiVpisaneVrednosti() {
    2. QFile file("test.txt");
    3.  
    4. QTextStream out(&file);
    5. out << "Let's see if it works." << endl;
    6. file.close();
    7. }
    To copy to clipboard, switch view to plain text mode 

    It does not save the string in test.text.
    Last edited by wysota; 13th March 2007 at 21:56. Reason: Corrected the bbcode

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: dynamically create folders with QT

    you forgot to open the file:
    Qt Code:
    1. void MojeOkno::vpisiVpisaneVrednosti() {
    2. QFile file("test.txt");
    3. file.open(QFile::WriteOnly | QFile::Truncate);
    4. QTextStream out(&file);
    5. out << "Let's see if it works." << endl;
    6. file.close();
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QFormbuilder : can not create widget of Q3ListView
    By user_mail07 in forum Qt Programming
    Replies: 5
    Last Post: 27th January 2007, 00:12
  2. how to create resource fork & data fork
    By jyoti in forum General Discussion
    Replies: 4
    Last Post: 28th November 2006, 18:20
  3. Replies: 1
    Last Post: 24th October 2006, 17:40
  4. How to create an Insert/Submit button for a form.
    By fnmblot in forum Qt Programming
    Replies: 5
    Last Post: 4th August 2006, 17:18
  5. How to create directories??
    By paranoid_android in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2006, 17:28

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.