QSetting的使用
作者:互联网
QSetting用于保存程序配置和初始化参数。在windows操作系统下用于保存ini配置文件和注册表
ini文件的格式:
保存配置到注册表
QSettings settings("MySoft","setting"); //保存到network节,键为ip,值为192.168.0.100 //settings.setValue("network/ip","192.168.0.100"); //保存到network节,键为gateway,值为192.168.0.1 //settings.setValue("network/gateway","192.168.0.1"); //设置节的默认值 //settings.beginGroup("network"); //settings.setValue("ip","192.168.0.100"); //settings.setValue("gateway","192.168.0.1"); //settings.endGroup(); //及时同步修改 settings.beginWriteArray("network"); for(int i=0;i<2;++i){ settings.setArrayIndex(i); settings.setValue("ip","192.168.0.100"); settings.setValue("gateway","192.168.0.1"); } settings.endArray(); settings.sync(); qDebug()<<settings.value("network/ip").toString()<<settings.value("network/gateway").toString();
保存配置到ini文件
QSetting settings("test.ini",QSettings::IniFormat); settings.setValue("network/ip","192.168.0.1"); settings.sync();
标签:setValue,network,settings,0.1,ip,192.168,使用,QSetting 来源: https://www.cnblogs.com/gravityma/p/16559198.html