0

Hi guys I have this code but it just overwrite the file. How can I just add text to the file?

 QFile file("E:/Qt/Qt codes/txt file/file");
 if(!file.open(QFile::WriteOnly | QFile::Text)){ 
       QMessageBox::warning(this,"Title","File not open.");
 }
 QTextStream out(&file);
 QString text = ui->plainTextEdit_2->toPlainText();
 out << text;
 file.flush();
 file.close();
       

Thanks.

1 Answers1

0

I think you can set flag QFile::Append

QFile inherits QIODevice.

here is doc.QIODevice Class

Haru
  • 1,884
  • 2
  • 12
  • 30