philwinder
14th November 2008, 15:33
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() )
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;
if( log->isWritable() )
*stream << QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") << ": " << theError << "\n";
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() )
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;
if( log->isWritable() )
*stream << QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") << ": " << theError << "\n";