QSetting的用法

settings = Qsettings(“MySoft”,”QtPad”)
Mainwindow = QmainWindow()
settings.setValue(“pos”,QVariant(Mainwindow.pos())
settings.setValue(“size”,QVariant(Mainwindow.size())


Qsetting.fileName() 返回写入注册表地址,或者INI文件路径

settings = QSettings("./QtPad.ini", QSettings.IniFormat)
settings.setValue("pos", QVariant(self.pos()))
settings.setValue("size", QVariant(self.size()))
就会在当前文件夹下产生一个QtPad.ini文件,打开后文件内容为:
[General]
[email protected](200 200)
[email protected](400 400)


QSettings settings(filename, QSettings::IniFormat); ///创建一个对象

settings.beginGroup(group);
QVariant value = settings.value(name, defaultValue);
settings.endGroup();

猜你喜欢

转载自www.cnblogs.com/countryboy666/p/11831715.html