QSettings ::NativeFormat在windows平台可以读写windows注册表.
QSettings *settings = new QSettings (const QString & fileName, Format format, QObject * parent = 0)
// 创建注册表
// fileName 必须是路径
QSettings *registry = new QSettings("HKEY_CURRENT_USER/", QSettings::NativeFormat);
// 写注册表
regisitry->setValue("regedit/hello", "hello");
// 读注册表
QString value = registry->value("regedit/hello", "hello").toString();
QSettings ::IniFormat可以读写ini格式的配置文件
QSettings *settings = new QSettings (const QString & fileName, Format format, QObject * parent = 0)
// 创建配置文件
// fileName 必须是路径
QSettings *config = new QSettings("./uer.ini", QSettings::InitFormat);
// 写配置文件
config->beginGroup("config");
config->setValue(user_key, user_value);
config->endGroup();
// 读配置文件
QString value = config->value(QString("config/") + user_key).toString();