CTZStef
CTZStef

Reputation: 1715

QSettings with multiple values for each key

Is there a way to have multiple values for each key, stored in a human-readable (no binaries) .ini file, using QSettings?

Something that could look like:

key_1=value_1,value2
key_2=value_1
...

Upvotes: 0

Views: 1795

Answers (2)

adderly
adderly

Reputation: 192

Well from depends how you want to access it, you could use

QVariant    value ( const QString & key, const QVariant & defaultValue = QVariant() ) const

in which you would be able to insert a QVariantList.

But i see there is a group format. http://doc.qt.digia.com/4.6/qsettings.html#childGroups

Upvotes: 0

Pavel Strakhov
Pavel Strakhov

Reputation: 40522

Yes, you should use QStringList type:

QStringList list;
list << "value_1" << "value2";
settings.setValue("key_1", list);

Output:

key_1=value_1, value2

Items that contains , will be quoted using "...".

Upvotes: 4

Related Questions