Results 1 to 5 of 5

Thread: Cannot append to QFile using QIODevice::Append

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    73
    Thanks
    11
    Thanked 7 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot append to QFile using QIODevice::Append

    Hi,
    Using the code below, I cannot get my program to open a text file and append to the end (log file). Instead, it overwrites all the data as if I had just sent a normal ReadWrite parameter. Have I done something wrong?

    Qt Code:
    1. log = new QFile( filePath + "/variant.log"); // Create a new file called variant.log
    2. Q_CHECK_PTR( log );
    3. if( !log->isOpen() )
    4. if( !log->open(QIODevice::Append | QIODevice::Text)) // open it
    5. return 1;
    6. stream = new QTextStream( log ); // Create a stream so that we can write to the file
    7. Q_CHECK_PTR( stream );
    8. return 0;
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. if( log->isWritable() )
    2. *stream << QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") << ": " << theError << "\n";
    To copy to clipboard, switch view to plain text mode 
    Last edited by philwinder; 14th November 2008 at 16:26.
    Best Regards,
    Phil Winder
    www.philwinder.com

Similar Threads

  1. Append mode in QFile
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2006, 11:47

Tags for this Thread

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.