Qasim Qasim - 7 months ago 37
C++ Question

Write a new text without losing the previous Qt

How can i Write a new text without losing the previous value

QString mFilename2 = "bin/bin_2.txt";

void stWrite(QString Filename,QString stringtext){
QFile mFile(Filename);

if(! | QIODevice::Text))
QMessageBox message_file_Write;
message_file_Write.warning(0,"Open Error"
,"could not to open file for Writing");
QTextStream out(&mFile);
out << stringtext;


Every time that okline_Edit is initialized
stWrite function called a new value in the file is poured .txt previous value is lost.

Or in other words
enter image description here

enter image description here


You need to set QIODevice::Append when you open() the file. | QIODevice::Append | QIODevice::Text)

Additionally, if you want each append to be on a new line, you will have to insert a \n as well.