QSettings - reading INI file

rreeves picture rreeves · Apr 25, 2013 · Viewed 17.7k times · Source

I create an INI file and then try to read it. There is no compile errors and the file is there but I'm not receiving any data in my QStringList

QFile checkConfig(configPath);
    if(checkConfig.exists())
    {
        QSettings* settings = new QSettings(configPath, QSettings::IniFormat);
        settings->beginGroup("General");
        const QStringList childKeys = settings->childKeys();
        QStringList values;
        foreach (const QString &childKey, childKeys)
            values << settings->value(childKey).toString();
        settings->endGroup();
        QString test = configPath;
        int a;
    }

this is my INI file

[General]
InterviewPath=C:/1234

Answer

rreeves picture rreeves · Apr 25, 2013

Problem stemmed from the INI not being created correctly.

QSettings settings(configPath, QSettings::IniFormat);
    settings.beginGroup("/General");
    settings.setValue("/InterviewPath", interviewPath);
    settings.endGroup();