天天看点

Qt ini文件

ini文件格式

节(section)

节用方括号括起来,单独占一行,例如:

[section]
           

键(key)

键(key)又名属性(property),单独占一行用等号连接键名和键值,例如:

name=value
           
; 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;