Results 1 to 2 of 2

Thread: file handling

  1. #1
    Join Date
    Oct 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default file handling

    Can anyone please explain file handling in Qt?
    Please specify how a file is created. I was earlier using c++, so please give an equivalent Qt code for the following.
    Qt Code:
    1. #include <fstream>
    2.  
    3. int main()
    4. {
    5. ofstream file("file1.txt");
    6. string s = "how are you?";
    7. file << s;
    8. }
    To copy to clipboard, switch view to plain text mode 
    the problem is that ofstream creates a file if it doesn't exist. But Qfile does not.

  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: file handling

    Quote Originally Posted by santakdalai90 View Post
    But Qfile does not.
    Sure it does. Did you actually try to open the file?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Read binary from file
    By weldpua2008 in forum Newbie
    Replies: 2
    Last Post: 3rd April 2009, 23:50
  2. large file handling
    By sakthi in forum Qt-based Software
    Replies: 1
    Last Post: 30th October 2008, 00:34
  3. 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
  4. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  5. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.