C++ (Qt) const QSettings::Format RigIniFormat = QSettings::registerFormat("ini", readRigIniFile, writeRigIniFile); QSettings iniFile(RigIniFormat, QSettings::UserScope, "", "");
C++ (Qt)bool readRigIniFile(QIODevice &device, QSettings::SettingsMap &map){ QFile f(&device); QString sectionName = ""; while(f.atEnd()) { QString s = f.readLine(); s = s.trimmed(); if(s.startsWith('[') && s.endsWith(']')) sectionName = s.mid(1, s.size() - 2); else { QStringList sl = s.split('='); if(sl.size() == 2) { sl[0] = sl[0].trimmed(); sl[1] = sl[1].trimmed(); map.insert(sectionName + "/" + sl[0], sl[1]); } } } return true;}
C++ (Qt)QSettings iniFile(fileName, RigIniFormat);
C++ (Qt)QSettings iniFile(RigIniFormat, QSettings::UserScope, "", "");
C++ (Qt) rigIniFileName = <Путь к ini-файлу>; const QSettings::Format RigIniFormat = QSettings::registerFormat("ini", readRigIniFile, writeRigIniFile); QSettings iniFile(rigIniFileName, RigIniFormat);
C++ (Qt)QString rigIniFileName; bool readRigIniFile(QIODevice &device, QSettings::SettingsMap &map){ QFile f(rigIniFileName); f.open(QIODevice::ReadOnly); QString sectionName = ""; while(!f.atEnd()) { QString s = f.readLine(); s = s.trimmed(); if(s.startsWith(';')) continue; else if(s.startsWith('[') && s.endsWith(']')) sectionName = s.mid(1, s.size() - 2); else { QStringList sl = s.split('='); if(sl.size() == 2) { sl[0] = sl[0].trimmed(); sl[1] = sl[1].trimmed(); map.insert(sectionName + "/" + sl[0], sl[1]); } } } return true;}
C++ (Qt) if(sl.size() == 2)
C++ (Qt)QFile f(&device);