【QT】续写文本存储到文件

续写文本到文件

使用标记QFile::WriteOnly| QIODevice::Append打开文件

cpp 复制代码
QString strConfigFile = "C:\\Users\\xiaosheng\\Desktop\\Log.txt";
QFile file1(strConfigFile);
QString strLog2;
strLog2 += "strKeyId" + "\n";
if (file1.open(QFile::WriteOnly| QIODevice::Append))
{
	QString strTempXml = strLog2;
	QTextStream out(&file1);
	out.setCodec("UTF-8");
	out << strTempXml;
	file1.close();
}

覆盖文本到文件

使用标记QFile::WriteOnly打开文件

cpp 复制代码
QString strConfigFile = "C:\\Users\\xiaosheng\\Desktop\\Log.txt";
QFile file1(strConfigFile);
QString strLog2;
strLog2 += "strKeyId" + "\n";
if (file1.open(QFile::WriteOnly))
{
	QString strTempXml = strLog2;
	QTextStream out(&file1);
	out.setCodec("UTF-8");
	out << strTempXml;
	file1.close();
}
相关推荐
Hello.Reader12 分钟前
tsrs 技术解析用 Rust 移植 TypeScript 7,类型检查还能怎样提速?
开发语言·rust·typescript
透明的玻璃杯28 分钟前
VS2015+QT 多线程
开发语言·qt
码匠许师傅1 小时前
【C++三方组件】mbedTLS:面向嵌入式的轻量 TLS
开发语言·c++
迪菲赫尔曼1 小时前
【基础篇 12】把环境与源码接起来:检查 GPU,再安装服务器上的项目
运维·服务器·开发语言·人工智能·python·yolo·目标检测
2601_962885721 小时前
2026 Python 股票数据接口选型指南(横评 + 决策树)
开发语言·python·区块链
Evand J2 小时前
【PMSM例程4】PMSM电阻辨识与模型补偿EKF,MATLAB例程。附下载链接,包运行成功
开发语言·matlab·电机·ekf·卡尔曼·pmsm
王仔小奶2 小时前
Rust 正在接管金融圈?深度拆解一份高薪 FinTech 岗位 JD
开发语言·金融·rust
小王C语言2 小时前
Qt常用控件:多元素控件,纵向列表,表格控件,树状控件
开发语言·qt
fanruitian2 小时前
python 可视化 panda seaborn matplotlib.pyplot
开发语言·python·matplotlib
jnrjian2 小时前
delete file shell 让 AI 写脚本
服务器·开发语言