Results 1 to 4 of 4

Thread: writing in text file

  1. #1
    Join Date
    Mar 2011
    Posts
    36
    Thanks
    30
    Qt products
    Qt4
    Platforms
    Windows

    Default writing in text file

    function::
    Qt Code:
    1. QFile file("input.txt");
    2. file.open(QIODevice::WriteOnly);
    3. QDataStream out(&file);
    4. out << QString("somedata");
    To copy to clipboard, switch view to plain text mode 

    I have been able to write in text file with this....
    but when I want to add another thing in same text file whenever I call the function for next time .....my previous value gets erased....on text file ,,and i don't want the data to be erased...
    please suggest me how to solve this problem??

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: writing in text file

    Did you try QIODevice::Append ?

  3. The following user says thank you to squidge for this useful post:

    ready (3rd July 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    36
    Thanks
    30
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: writing in text file

    No I didn't ...and I have very little idea about this...
    would you please mind elaborating this??

  5. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: writing in text file

    Something like:

    Qt Code:
    1. file.open(QIODevice::WriteOnly | QIODevice::Append);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Writing text file in execlusive mode
    By viglu in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2011, 22:17
  2. Writing the text within a text edit to a file
    By Splatify in forum Newbie
    Replies: 4
    Last Post: 23rd February 2011, 22:48
  3. writing to a text-file
    By QtBros61 in forum Newbie
    Replies: 7
    Last Post: 9th April 2010, 11:15
  4. Writing raw bytes as text?
    By DiamonDogX in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2009, 16:56
  5. Writing Text on a Rectangle!!!
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2006, 10:23

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.