Results 1 to 3 of 3

Thread: Can't create folder

  1. #1
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Can't create folder

    Hi,

    I read many many tutorials in internet how we can create new folder(directory) using QT.Unfortunately i can't have success with no one.I'm on Mac OS X 10.10 with Qt 5.7.

    What i make is:

    Qt Code:
    1. QString path1 = "Documents";
    2.  
    3. QDir dir(path1);
    4. if(!dir.exists())
    5. {
    6. qDebug() << "Creating " << path1 << "directory";
    7. dir.mkdir(path1);
    8. }
    9. else
    10. {
    11. qDebug() << path1 << " already exists";
    12. }
    To copy to clipboard, switch view to plain text mode 

    I also can't understand how to create folder in Users/Library/Application Support/My_program_name_folder
    using QStandardPaths in this case QStandardPaths:ataLocation.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can't create folder

    Your code tries to create a directory "Documents" inside a non-existing directory.

    Quote Originally Posted by cpuinthebrain View Post
    using QStandardPaths in this case QStandardPaths:ataLocation.
    Maybe something like
    Qt Code:
    1. QDir root = QDir::root();
    2. root.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Sep 2012
    Posts
    44
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Can't create folder

    Thank you!

Similar Threads

  1. Create folder at specfic path on runtime
    By anh5kor in forum Newbie
    Replies: 2
    Last Post: 19th January 2016, 10:01
  2. how to create folder in root directory using QT
    By iswaryasenthilkumar in forum Newbie
    Replies: 1
    Last Post: 24th February 2015, 16:21
  3. QFileDialog to create folder
    By qt_developer in forum Newbie
    Replies: 1
    Last Post: 12th April 2013, 19:48
  4. Can't create folder if file with same name exists
    By Barry79 in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2009, 16:33
  5. Create folder
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2007, 21:02

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.