Open QFile for appending

sashoalm picture sashoalm · Dec 13, 2012 · Viewed 32.1k times · Source

How can I open a QFile for appending, i.e. the equivalent of

FILE *f = fopen("myfile.txt", "a");

Answer

Maciej picture Maciej · Dec 13, 2012

Open the file in QIODevice::Append mode:

QFile f(...);
if (f.open(QIODevice::WriteOnly | QIODevice::Append)) {
  ...
}

See also the documentation.