Results 1 to 3 of 3

Thread: Create a file

  1. #1
    Join Date
    Dec 2007
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Create a file

    How would I create a file with Qt? I know how to open an existing file with Qt using QFile::open(), but how would I actually create a file? QFile::open() doesn't seem to create files (when I'm opening them in QIODevice::ReadWrite mode).
    Last edited by wysota; 28th January 2008 at 10:21. Reason: reformatted to look better

  2. #2
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Create a file

    Quote Originally Posted by bfr View Post
    How would I create a file with Qt? I know how to open an existing file with Qt using QFile:pen(), but how would I actually create a file? QFile:pen() doesn't seem to create files (when I'm opening them in QIODevice::ReadWrite mode).
    By the use
    Qt Code:
    1. QFile file(fileName);
    To copy to clipboard, switch view to plain text mode 
    of this you can create a file. As well as bool exists () const checks file exists or not.
    Take a look of http://doc.trolltech.com/4.3/qfile.html .
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  3. #3
    Join Date
    Jan 2008
    Location
    Silicon valley
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Create a file

    Quote Originally Posted by bfr View Post
    QFile::open() doesn't seem to create files (when I'm opening them in QIODevice::ReadWrite mode).
    It does:

    Qt Code:
    1. QFile file("/tmp/q");
    2. file.open( QIODevice::WriteOnly);
    3. file.write( "qq");
    4. file.close();
    To copy to clipboard, switch view to plain text mode 

    I just run the above code, and it worked. Maybe you have permission problems? Did you check file.error() ?

Similar Threads

  1. Replies: 4
    Last Post: 18th December 2009, 18:55
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. How to create a access file .mdb
    By aiikcmo in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:06
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. create file in another directory
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 10:04

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.