#include "WriteLog.h" void WriteLog::SaveLog(QString msg) { QString sFilePath = "test.txt"; QFile file(sFilePath); if (file.size() > 1024 * 1024 * 10) { file.remove(); file.deleteLater(); return; } //·½Ê½£ºAppendΪ׷¼Ó£¬WriteOnly£¬ReadOnly if (!file.open(QIODevice::Append | QIODevice::Text)) { return; } QTextStream out(&file); out << msg << endl; out.flush(); file.close(); }