ini文件格式
节(section)
节用方括号括起来,单独占一行,例如:
[section]
键(key)
键(key)又名属性(property),单独占一行用等号连接键名和键值,例如:
name=value
注释(comment)
注释使用英文分号(;)开头,单独占一行。在分号后面的文字,直到该行结尾都全部为注释,例如:
; comment text
写入
QSettings *configIniWrite = new QSettings("test.ini", QSettings::IniFormat);
configIniWrite->setValue("/Setting/name", "furong");
delete configIniWrite;
读取
QSettings *configIniRead = new QSettings(sctemp, QSettings::IniFormat);
configIniRead->setIniCodec(QTextCodec::codecForName("UTF-8")); //中文读取
QString name = configIniRead->value("/Setting/name").toString();
delete configIniRead;