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]
pos=@Point(200 200)
size=@Size(400 400)


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

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

posted @ 2019-11-10 20:39  countryboy666  阅读(428)  评论(0编辑  收藏  举报