Open QFile for appending

2019-01-09 17:06发布

问题:

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

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

回答1:

Open the file in QIODevice::Append mode:

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

See also the documentation.



标签: c++ file qt qfile