QIODevice::Append is not working as expected
Unsolved
General and Desktop
-
using QT 4.8 in QtCreator.
I want to append a new line to a text file every time I open and write and close. But this code is overwriting the line that is already in the file.
QFile efile; QString filepath = "/home/user12/cal/logs/Sensor_" + sensor + "_Temp_" + QString::number(CURTEMP*10) + "_LOG.log"; QFile efile(filepath); if(efile.open(QIODevice::WriteOnly) | QIODevice::Append) { QTextStream qts(&efile); if(validIn) { qts << "(Pre-Temp Setup) For Power Level " << (countIn - qAbs(MinCW_PowerLevel)) << ": Pre-Amp Power = " << PreAmpPowerLevelArray[PowerLevelCount] << " and Power Meter = " << meterReading << " (VALID)\n"; }else if(!validIn) { qts << "(Pre-Temp Setup) For Power Level " << (countIn - qAbs(MinCW_PowerLevel)) << ": Pre-Amp Power = " << PreAmpPowerLevelArray[PowerLevelCount] << " and Power Meter = " << meterReading << " (INVALID)\n"; } qDebug()<<"file open"; } efile.close();
-
Glad you found out and thanks for sharing !
Please mark the thread as solved so that other forum users may know a solution has been found :-)