Results 1 to 3 of 3

Thread: QDir create multiple dirs

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QDir create multiple dirs

    Hi,

    Can QDir create a directory with sub directories?

    I have "/data" and I want to create "/data/dir1/subdir1"

    Is there a way to create "dir1" and "subdir1" at same time or have I to create one by one?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDir create multiple dirs

    Hi,

    See my tests:

    QDir dir;

    First Case: OK: The subdir test1 will be created successfully
    if( !dir.mkdir("/root/test1") )
    qDebug("error);
    else
    qDebug("ok"); // <<---- OK

    Second Case: NO: The subdir test2 will not create successfully
    if( !dir.mkdir("/root/test1/test2") )
    qDebug("error); // <<--- ERROR
    else
    qDebug("ok");

    Then I think that from the second level will have of to be created manually

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDir create multiple dirs

    have a look at QDir::mkpath()

  4. The following 2 users say thank you to caduel for this useful post:

    Phlucious (29th September 2014), ^NyAw^ (4th March 2009)

Similar Threads

  1. how to create multiple windows in QT
    By durgarao in forum Qt Tools
    Replies: 1
    Last Post: 9th January 2009, 14:47
  2. How to create filmstrip - multiple images in a single file
    By jessiemmichael in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 08:30

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.