Works for me
#include <QDebug>
#include <QSettings>
#include <QStringList>
#include <QTemporaryFile>
#include <QTextStream>
int main()
{
if ( !tmpFile.open() ) {
return 1;
}
const QString fileName
= tmpFile.
fileName();
stream <<
QLatin1String( "[Env]" ) << endl <<
"Driver=QSQLITE" << endl;
stream << "Name=some name" << endl;
tmpFile.close();
qDebug() << "childGroups=" << settings.childGroups();
qDebug() << "Driver=" << settings.value("Env/Driver");
qDebug() << "Name=" << settings.value("Env/Name");
return 0;
}
#include <QDebug>
#include <QSettings>
#include <QStringList>
#include <QTemporaryFile>
#include <QTextStream>
int main()
{
QTemporaryFile tmpFile;
if ( !tmpFile.open() ) {
return 1;
}
const QString fileName = tmpFile.fileName();
QTextStream stream( &tmpFile );
stream << QLatin1String( "[Env]" ) << endl << "Driver=QSQLITE" << endl;
stream << "Name=some name" << endl;
tmpFile.close();
QSettings settings( fileName, QSettings::IniFormat );
qDebug() << "childGroups=" << settings.childGroups();
qDebug() << "Driver=" << settings.value("Env/Driver");
qDebug() << "Name=" << settings.value("Env/Name");
return 0;
}
To copy to clipboard, switch view to plain text mode
I get
childGroups= ("Env")
childGroups= ("Env")
Driver= QVariant(QString, "QSQLITE")
Name= QVariant(QString, "some name")
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks