码迷,mamicode.com
首页 > 其他好文 > 详细

Qt 配置文件QSettings

时间:2016-06-21 12:43:21      阅读:653      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/coolbear/p/5603165.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!