I would do it like this:
say that we have two functions that are included in the load and save class for using the registry, you need to specify the name and editor of the application:
QSettings settings("<MyEditorName>","<myAppName>");
saveScores(&settings);
loadScores(&settings);
To use a file, you must specify the path and file format:
QSettings settings("<filepath>",QSettings::iniFormat);
saveScores(&settings);
loadScores(&settings);
from your code and documentation, the member function will be as follows the class calls the grading vector (QVector mScores)
To save points:
void myClass::saveScores(QSettings* iSettings){
iSettings->beginGroup("Scores");
iSettings->beginWriteArray("results");
for(int i=0; i<mScores.count();i++){
iSettings->setArrayIndex(i);
iSettings->setValue("result",mScores[i]);
}
iSettings->endArray();
iSettings->endGroup();
}
to load points
void myClass::loadScores(QSettings* iSettings){
iSettings->beginGroup("Scores");
int size = iSettings->beginReadArray("results");
mScores.resize(size);
for(int i=0;i<size;i++){
iSettings->setArrayIndex(i);
mScores[i] = iSettings->value("results").toInt();
}
iSettings->endArray();
iSettings->endGroup();
}
, ,