code
QSettings *configIniRead = new QSettings("config.ini", QSettings::IniFormat);
//将读取到的ini文件保存在QString中,先取值,然后通过toString()函数转换成QString类型
QString ipResult = configIniRead->value("/ip/second").toString();
QString portResult = configIniRead->value("/port/open").toString();
//打印得到的结果
qDebug() << ipResult;
qDebug() << portResult;
delete configIniRead;
config.ini 可以用#注释,可以用[]进行分组
[ip]
first=192.168.0.1
second=127.0.0.127# here is port
[port]
open=2222