hmmm... I guess you are right. My little test app seems to work correctly:
#include <QSettings>
#include <QString>
void saveSettingsArray()
{
QSettings settings
("MKrueger",
"SettingsTest");
settings.beginWriteArray("blogAccounts");
for (int i = 0; i <= 2; ++i)
{
// This is a new account, we will save it to the end of the list ...
settings.setArrayIndex(i);
settings.setValue("accountName", "Test-Account: " +
settings.setValue("hostName", "www.michael-krueger.org");
}
settings.endArray();
}
void loadSettingsArray()
{
QSettings settings
("MKrueger",
"SettingsTest");
int size = settings.beginReadArray("blogAccounts");
for (int i = 0; i < size; ++i)
{
// Select the data set
settings.setArrayIndex(i);
//
temp += settings.value("accountName").toString();
qDebug(temp.toAscii());
temp = "hostName: ";
temp += settings.value("hostName").toString();
qDebug(temp.toAscii());
}
settings.endArray();
}
int main(int /*argc*/, char /**argv[]*/)
{
saveSettingsArray();
//
loadSettingsArray();
return 0;
}
#include <QSettings>
#include <QString>
void saveSettingsArray()
{
QSettings settings("MKrueger", "SettingsTest");
settings.beginWriteArray("blogAccounts");
for (int i = 0; i <= 2; ++i)
{
// This is a new account, we will save it to the end of the list ...
settings.setArrayIndex(i);
settings.setValue("accountName", "Test-Account: " +
QString::number(i));
settings.setValue("hostName", "www.michael-krueger.org");
}
settings.endArray();
}
void loadSettingsArray()
{
QSettings settings("MKrueger", "SettingsTest");
int size = settings.beginReadArray("blogAccounts");
for (int i = 0; i < size; ++i)
{
// Select the data set
settings.setArrayIndex(i);
//
QString temp("accountName: ");
temp += settings.value("accountName").toString();
qDebug(temp.toAscii());
temp = "hostName: ";
temp += settings.value("hostName").toString();
qDebug(temp.toAscii());
}
settings.endArray();
}
int main(int /*argc*/, char /**argv[]*/)
{
saveSettingsArray();
//
loadSettingsArray();
return 0;
}
To copy to clipboard, switch view to plain text mode
The app above does work as expected. I need to double check my application.
The output is correctly:
micha@helium:~/develop/QSettingsTest> ./QSettingsTest
accountName: Test-Account: 0
hostName: www.michael-krueger.org
accountName: Test-Account: 1
hostName: www.michael-krueger.org
accountName: Test-Account: 2
hostName: www.michael-krueger.org
micha@helium:~/develop/QSettingsTest>
micha@helium:~/develop/QSettingsTest> ./QSettingsTest
accountName: Test-Account: 0
hostName: www.michael-krueger.org
accountName: Test-Account: 1
hostName: www.michael-krueger.org
accountName: Test-Account: 2
hostName: www.michael-krueger.org
micha@helium:~/develop/QSettingsTest>
To copy to clipboard, switch view to plain text mode
... very strange, very strange ...
Bookmarks