标签:address setting log 打开 add set 信息 qstring 参数
用户通常希望应用程序记住其设置。在windows中,这些设置保存在注册表中,ios在属性文件列表中,而unix,在缺乏标准的情况下,其存储在ini文本中。QSettings有两种存储格式:QSettings::NativeFormat(在windows平台可读写注册表)、QSettings::IniFormat(读写ini文件)、QSettings::InvalidFormat
QSettings(const QString & organization, const QString & application = QString(), QObject * parent = 0)
settings.setValue("editor/wrapMargin", 68);
int margin = settings.value("editor/wrapMargin").toInt();
int margin = settings.value("editor/wrapMargin", 80).toInt();
QSetings settings(("HKEY_CURRENT_USER/", QSettings::NativeFormat);
settings.setValue("regedit/test","green");//设置key-value键值对
QString value = settings.value("regedit/test");//读取key对应的value
#include <QApplication>
#include <QSettings>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSettings settings("E:/QTProject/BLOG/Settings_test/test.ini", QSettings::IniFormat);
settings.setValue("Student/name", "ChengKeKe");
settings.setValue("Student/sex", "man");
settings.setValue("Student/age", 24);
settings.setValue("Address", "Xi‘an");
QString name = settings.value("Student/name").toString();
QString sex = settings.value("Student/sex").toString();
return a.exec();
}
标签:address setting log 打开 add set 信息 qstring 参数
原文地址:https://www.cnblogs.com/stones-dream/p/10153787.html