----|打开.ini配置文件
QSettings settings(strConfigFile, QSettings::IniFormat);
----|读数据
settings.beginGroup("basic"); //进入[basic]
settings.value("enable_english").toBool() //取值并转bool类型
settings.endGroup(); //退出[basic]
settings.beginGroup("database"); //进入[database]
tableListFileName = settings.value("tablelistfile").toString(); //取值并转为string
int type = settings.value("type").toInt(); //取值并转int类型
settings.endGroup(); //退出[database]
//value第二参数是默认值,如果value不存在就使用默认参数
settings.beginGroup("query");
m_nSingleExportMax = settings.value("SingleExportMax",500).toInt();
settings.endGroup();
----|写数据 //写数据不建议使用QSetting函数,会破坏配置文件的注释
settings.beginGroup("server");
settings.setValue("ip", "192.168.1.120");
settings.setValue("port", 10001);
settings.endGroup();
[basic]
enable_english=false
enable_pie_plot=false
login_timeout_sec=300
measure_compare_display=false
[database]
tablelistfile=config/db.table.list.txt
type=0
[query]
SingleExportMax=2000
SinglePageSize=100
#database/type=mysql or sqlite
#type value 0 : sqlite 1 : mysql