Qt 配置文件QSettings
Posted 酷熊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt 配置文件QSettings相关的知识,希望对你有一定的参考价值。
QString appDirPath = QCoreApplication::applicationDirPath();
QSettings* configIniRead = new QSettings(appDirPath+"/setup.ini", QSettings::IniFormat);
// test
/*
configIniRead->beginGroup("mainwindow");
configIniRead->setValue("size", 122);
configIniRead->setValue("fullScreen", 1);
configIniRead->endGroup();
configIniRead->beginGroup("outputpanel");
configIniRead->setValue("visible", 1);
configIniRead->endGroup();
settings.setValue("fridge/color", QColor(Qt::white));
settings.setValue("fridge/size", QSize(32, 96));
settings.setValue("sofa", true);
settings.setValue("tv", false);
QStringList keys = settings.allKeys();
// keys: ["fridge/color", "fridge/size", "sofa", "tv"]
QStringList keys = settings.childKeys();
// keys: ["sofa", "tv"]
QStringList groups = settings.childGroups();
// groups: ["fridge"]
configIniRead->beginWriteArray("logins");
for (int i = 0; i < 3; ++i) {
configIniRead->setArrayIndex(i);
configIniRead->setValue("userName", i);
configIniRead->setValue("password", "0a");
}
configIniRead->endArray();
*/
以上是关于Qt 配置文件QSettings的主要内容,如果未能解决你的问题,请参考以下文章
QT 登录记住密码方法之一:Qt QSettings读写配置文件
Qt配置信息设置(QSettings在不同平台下的使用路径)
Qt读写三种文件,QSettings读ini配置文件,QJsonDocument读JSON文件,QDomDocument读xml文件