今天给大家介绍下一种简单的配置文件ini的读写,一句话:简单
1、#include <QSettings>
2、ini文件书写格式:
[DevOption]
mainFun=25
subFun=40
service=1
3、读写ini文件
//qt写入ini配置文件 QSettings settings("Option.ini",QSettings::IniFormat); settings.beginGroup("DevOption"); settings.setValue("mainFun",25); settings.setValue("subFun",40); settings.setValue("service",1); settings.endGroup(); //读取ini QSettings settingsread("Option.ini",QSettings::IniFormat); int mainFun = settingsread.value("DevOption/mainFun").toInt(); QString service = settingsread.value("DevOption/service").toString();
4、这种.ini配置文件书写简单易懂,也易于操作,也是比较常见的配置文件