Hi All,
I am trying to use QSettings to read the INI file but I have try few times but still fail to read it
The format for INI file is like below:
[System.Setting]
auto_check_update=false
auto_check_mode=weekly
Thanks
Hi All,
I am trying to use QSettings to read the INI file but I have try few times but still fail to read it
The format for INI file is like below:
[System.Setting]
auto_check_update=false
auto_check_mode=weekly
Thanks
Found out the way
QString strKey("System.Setting/");
QSettings * settings = 0;
settings = new QSettings( m_strWorkingPath, QSettings::IniFormat );
ret = settings->value( strKey + "auto_check_update", "r").toBool();
strMode = settings->value( strKey + "auto_check_mode", "r").toString();
Better use QSettings::beginGroup() and QSettings::endGroup().
Cantora (5th June 2009)
Hi, for me
The format for INI file is like below:
[players]
player0name=mike
player0surname=jane
player1name=scootie
...
...
I am trying to use QSettings to read the INI file..
I tried this:
settings = new QSettings("config.ini",QSettings::IniFormat);
settings->beginGroup("players");
int size = settings->beginReadArray("player");
ui->lineEdit_2->setText(QString::number(size)); // this is value-test
for (int index = 0; index < size; ++index)
{
settings->setArrayIndex(index);
ui->choosePlayerBox->addItem(settings->value("name").toString());
}
settings->endArray();
settings->endGroup();
But it doesn`t work..
I tried also:
[players]
player/0/name=mike
player/0/surname=jane
player/1/name=scootie
...
...
But it also doesn`t work..
Any ideas ?
Thanks
try this example:
Qt Code:
settings.beginGroup("players"); qDebug() << settings.value(childKey); settings.endGroup();To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
ok, i have ini file like:
[user]
0/name=lukasz
0/wins=3
0/loses=3
1/name=pawel
1/wins=1
1/loses=5
2/name=anna
2/wins=1
2/loses=5
and my code is:
Qt Code:
settings->beginGroup("user"); { ui->choosePlayerBox->addItem(settings->value(childKey).toString()); // should add lukasz, 3, 3, pawel...., but it doesn`t work } settings->endGroup();To copy to clipboard, switch view to plain text mode
Any ideas ?
you code will not work, because "0/name" it's a key, not a group.
I suggest you to review format on your ini-file or use xml instead.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
candyshop (16th November 2009)
Hi
my .ini file is
[System.Setting]
auto_check_update=false
auto_check_mode=weekly
& the code to read is
QString strKey("System.Setting/");
QSettings * settings = 0;
settings = new QSettings( file_path, QSettings::IniFormat );
QString strMode = settings->value( strKey + "auto_check_mode", "r").toString();
no problem with the code compiling & running. when i try to print strMode program is unexpectedly finising.. this is happening with QString, Date (Derived data types). but fine with basic data types like int, float, bool...
using printf to print the values. qDebug is not working in this project. what could be the problem?
Bookmarks