qt 读写文件
来源:互联网 发布:js对象私有属性 编辑:程序博客网 时间:2024/05/20 14:26
1)按行读取
QString apppath = QApplication::applicationDirPath() + "/host.txt";
// qDebug()<<"apppath = "<<apppath;
QFile hostfile(apppath);
if (hostfile.exists()){
hostfile.open(QIODevice::ReadOnly);
QTextStream stream(&hostfile);
program.hostURL = stream.readLine();
program.basePath = stream.readLine();
program.htmlUrl = stream.readLine();
program.demensionUrl = stream.readLine();
// qDebug()<<"program.hostURL="<<program.hostURL;
// qDebug()<<"program.hostPort="<<program.hostPort;
hostfile.close();
}
2)写文件
QFile accountFile(QApplication::applicationDirPath() + "/account.txt");
accountFile.open(QIODevice::WriteOnly)
if (!accountFile.write(accountName.toStdString().c_str()))
{
//保存错误
}
accountFile.close();
- Qt|Qt读写ini文件
- QT 文件读写操作
- Qt 文件读写操作
- Qt读写ini文件
- Qt入门-文件读写
- Qt 读写XML文件
- QT 读写Xml文件
- QT 文件读写操作
- Qt读写ini文件
- QT读写ini文件
- Qt txt文件读写
- Qt读写ini文件
- QT 文件读写操作
- QT 文件读写操作
- Qt 文件读写
- qt文件读写
- Qt文件读写
- Qt入门-文件读写
- 建造者模式
- hadoop-2.6.4本地编译
- Git使用,实战版
- 查看类是否包含在jar包中
- POJ 2356 Find a multiple(抽屉原理)
- qt 读写文件
- 数理逻辑1 -- 命题演算5
- 异步委托四步走
- JVM高级特性与实践(九):类加载器 与 双亲委派模式(自定义类加载器源码探究ClassLoader)
- Hibernate的QBC与HQL分页查询
- 电脑新建文件或者更改东西,无法刷新,提示错误---解决办法
- PAT B1013.数素数
- MYSQL学习笔记(六)创建计算字段
- strcat字符串拼接函数