//Write
QSettings settings("zhu.ini",QSettings::IniFormat);
settings.beginGroup("mainwindow");
settings.setValue("size", 100);
settings.setValue("name", settings.applicationName());
settings.endGroup();
settings.beginGroup("outputpanel");
settings.setValue("visible", true);
settings.endGroup();
settings.beginWriteArray("logins");
for (int i = 0; i < 5; ++i) {
settings.setArrayIndex(i);
settings.setValue("userName", i);
settings.setValue("password", i*100);
}
settings.endArray();
settings.sync();
//Read
QSettings settings("zhu.ini",QSettings::IniFormat);
settings.beginGroup("mainwindow");
int size = settings.value("size").toInt();
QString name = settings.value("name").toString();
settings.endGroup();
int c = settings.beginReadArray("logins");
for(int i = 0;i<c;i++){
settings.setArrayIndex(i);
int userName = settings.value("userName").toInt();
int password = settings.value("password").toInt();
}
settings.endArray();