打开 QFile 进行追加

2021-12-09 00:00:00 file qt c++ qfile

如何打开一个 QFile 进行追加,即相当于

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

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

推荐答案

QIODevice::Append模式打开文件:

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

另请参阅文档.

相关文章