【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();
}
相关推荐
敢敢のwings1 天前
智元 GO-2 与 AgiBot-World 深度解读
开发语言·后端·golang
yaoxin5211231 天前
503. Java 反射 - 编写 ServiceFactory 类
java·开发语言·python
一个帅气昵称啊1 天前
.Net C# AI智能体开发-快速开始
开发语言·c#·.net
冬夜戏雪1 天前
agent的trace 和eval
开发语言·前端·javascript
Sagittarius_A*1 天前
Burst Lab | PHP 审计 13|反序列化(三):POP 链构造与 Gadget Chain 分析
开发语言·web安全·php·代码审计·反序列化
职场的momo1 天前
11个后端与AI岗位同时开放:Java、网关、推理优化怎么匹配
java·开发语言·人工智能
蓝速科技1 天前
蓝速科技丨新旧楼宇混杂场景下会议室预约门牌屏一体化改造方案
开发语言·科技·php
梦想的旅途21 天前
Python实现企业微信文本消息发送
开发语言·python·企业微信
丰锋ff1 天前
基于 Qt 的智能门禁系统
qt·学习
大鹏说大话1 天前
美业微信会员系统哪个好
开发语言