Results 1 to 3 of 3

Thread: Create File with QFile

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Create File with QFile

    How to force create path if it not exists with QFile?

    Qt Code:
    1. QFile f("/tmp/this/path/is/not/exists/test.php");
    2. if (!f.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
    3. qDebug() << "Gagal:" << f.errorString();
    4. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Create File with QFile

    presume you do not have rights to create a file there?
    Last edited by amleto; 19th April 2013 at 21:42.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Create File with QFile

    Quote Originally Posted by wirasto View Post
    How to force create path if it not exists with QFile?
    QFile creates files not directories. Look at QDir::makePath()

  4. The following user says thank you to ChrisW67 for this useful post:

    wirasto (20th April 2013)

Similar Threads

  1. How to create in memory QFile
    By pratham_shah in forum Qt Programming
    Replies: 13
    Last Post: 10th August 2012, 12:25
  2. Replies: 4
    Last Post: 9th May 2011, 09:52
  3. Replies: 5
    Last Post: 27th May 2009, 12:49
  4. Replies: 3
    Last Post: 28th March 2009, 15:37
  5. QFile can't read a file
    By Raccoon29 in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2009, 20:24

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
  •  
Qt is a trademark of The Qt Company.