INI[SET_1]ID=User2Name=name1 [SET_2]ID=User2Name=name2 ... [SET_N]ID=UserNName=nameN
C++ (Qt)QSettings settings("mysettings.ini", QSettings::IniFormat);const QString id1 = settings.value("SET_1/ID").toString();const QString name1 = settings.value("SET_1/Name").toString();...
C++ (Qt) settings.beginGroup("SET_1"); settings.setValue("ID", User1); settings.setValue("Name", name1); settings.endGroup(); .... settings.beginGroup("SET_N"); settings.setValue("ID", UserN); settings.setValue("Name", nameN); settings.endGroup();
INISETS=SET_1;SET_2; ... ;SET_N
INI[ae]CountryName=United Arab EmiratesRegion=Middle East [ar]CountryName=Argentina Region=America
C++ (Qt) QString fileName = "config.ini"; if (!QFile::exists(fileName)) qDebug() << "FILE" << fileName <<" DON'T EXIST" << endl; QSettings settings(fileName, QSettings::IniFormat); QStringList groups = settings.childGroups(); for (int i = 0; i < groups.size(); ++i) { qDebug() << groups.at(i) << endl; settings.beginGroup(groups.at(i)); qDebug() << "CountryName:" << settings.value("CountryName").toString() << endl; qDebug() << "Region:" << settings.value("Region").toString() << endl; settings.endGroup(); }
C++ (Qt)QString fileName = "config.ini"; if (!QFile::exists(fileName)) { qDebug() << "FILE" << fileName <<" DON'T EXIST" << endl; //создаем тут} else { QSettings settings(fileName, QSettings::IniFormat); QStringList groups = settings.childGroups(); for (int i = 0; i < groups.size(); ++i) { qDebug() << groups.at(i) << endl; settings.beginGroup(groups.at(i)); qDebug() << "CountryName:" << settings.value("CountryName").toString() << endl; qDebug() << "Region:" << settings.value("Region").toString() << endl; settings.endGroup(); }}
C++ (Qt)QString fileName = "config.ini"; if (!QFile::exists(fileName)) { qDebug() << "FILE" << fileName <<" DON'T EXIST" << endl; QSettings settings(fileName, QSettings::IniFormat); //вариант 1 settings.setValue("ae/CountryName", "United Arab Emirates"); settings.setValue("ae/Region", "Middle East"); //вариант 2 settings.beginGroup("ar"); settings.setValue("CountryName", "Argentina"); settings.setValue("Region", "America"); settings.endGroup();} else { QSettings settings(fileName, QSettings::IniFormat); QStringList groups = settings.childGroups(); for (int i = 0; i < groups.size(); ++i) { qDebug() << groups.at(i) << endl; settings.beginGroup(groups.at(i)); qDebug() << "CountryName:" << settings.value("CountryName").toString() << endl; qDebug() << "Region:" << settings.value("Region").toString() << endl; settings.endGroup(); }}