Write a txt doc
-
Hi,
I have the following problem, when I want to write to a txt document, I write only the last added. How could make it so when you go inserting text, this is written on the next line?code:
@ void readDoc(QString filename)
{
QFile file(filename);
QString linea;if(!file.open(QFile::ReadOnly | QFile::Text) { return; } QTextStream in(&file); while(!in.atEnd()) { linea = in.readLine(); qDebug() << linea; } file.close(); void writeDoc(QString filename, QString text) { QFile file(filename); QTextStream out(&file); if(!file.open(QFile::WriteOnly | QFile::Text) { return; } out << text; }@
The value of text is the text of the lineEdit.
-
open the file with QIODevice::Append mode.