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
Problem stemmed from the INI not being created correctly.
QSettings settings(configPath, QSettings::IniFormat);
settings.beginGroup("/General");
settings.setValue("/InterviewPath", interviewPath);
settings.endGroup();
Do not use settings->beginGroup("General");
QCoreApplication a(argc, argv);
QSettings* settings = new QSettings("d:/a.ini", QSettings::IniFormat);
// settings->beginGroup("General");
const QStringList childKeys = settings->childKeys();
QStringList values;
foreach (const QString &childKey, childKeys)
values << settings->value(childKey).toString();
// settings->endGroup();
qDebug()<<values;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With