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?
log = new QFile( filePath
+ "/variant.log");
// Create a new file called variant.log Q_CHECK_PTR( log );
if( !log->isOpen() )
return 1;
stream
= new QTextStream( log );
// Create a stream so that we can write to the fileQ_CHECK_PTR( stream );
return 0;
log = new QFile( filePath + "/variant.log"); // Create a new file called variant.log
Q_CHECK_PTR( log );
if( !log->isOpen() )
if( !log->open(QIODevice::Append | QIODevice::Text)) // open it
return 1;
stream = new QTextStream( log ); // Create a stream so that we can write to the file
Q_CHECK_PTR( stream );
return 0;
To copy to clipboard, switch view to plain text mode
if( log->isWritable() )
*stream <<
QDateTime::currentDateTime().
toString("dd.MM.yy hh:mm:ss.zzz") <<
": " << theError <<
"\n";
if( log->isWritable() )
*stream << QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") << ": " << theError << "\n";
To copy to clipboard, switch view to plain text mode
Bookmarks