Text file's content deleted every time program runs

  • Hi, I have to add information to a text file but every time I open the program the previous contents of the file are deleted. This is the code:

    The following is what is defined in the QMainWindows builder. Where flow1 and file1 are pointers defined with the private label in QMainWindows class

     file1= new QFile ("Repairs and failures.txt");
     flow1= new QTextStream (file1);

    The following is the code that is performed in a clicked event

        QDate date;
        QString fecha;
        QString texto;

    What I'm doing wrong?

    Thanks and regards

  • See flags QIODevice::OpenMode. With QIODevice::WriteOnly the device will be truncated if possible. What you want is QIODevice::Append.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.