Header files

#ifndef PRJINI_H #define PRJINI_H class QPrjIni {private:// stop instantiating QPrjIni(); public: static bool write(QString section, QString key, QString value, QString path); static bool read(QString section, QString key, QString &value, QString path); }; #endif // PRJINI_H\

\

2. Source files

#include “prjini.h”

#include

QPrjIni::QPrjIni() { } bool QPrjIni::write(QString section, QString key, QString value, QString path) { if (path.isEmpty() || key.isEmpty()) { return false; } else {// Create configuration file operation object QSettings *config = new QSettings(path, QSettings::IniFormat); // write the information to the config file config->beginGroup(section); config->setValue(key, value); config->endGroup(); // delete config; return true; } } bool QPrjIni::read(QString section, QString key, QString &value, QString path) { value = QString(“”); if (path.isEmpty() || key.isEmpty()) { return false; } else {// Create configuration file operation object QSettings *config = new QSettings(path, QSettings::IniFormat); Value = config->value(section + “/” + key).tostring (); // delete config; return true; } \

}

\

Application cases

// Software name and version QString softname; QString softver; QString path = qApp->applicationDirPath() + “/config.ini”; QPrjIni::read(“setting”, “softname”, softname, path); QPrjIni::read(“setting”, “softver”, softver, path); \