I am using QSettings
to parse an ini file: QSettings cfg(path, QSettings::IniFormat);
When I obtain a value QVariant qv = cfg.value("title");
containing a comma the variant contains a QStringList
instead of a QString
title=foo => QString
title=foo,bar => QStringList
How can I always get strings, or at least obtain the original line ( title=foo,bar
) ?
You have at least two ways to address this issue, all of them presented below:
test.ini
main.cpp
main.pro
Build and Run
Output
In other words, use quotes for strings with special characters or join the strings manually in the list. The former is far better if it is under your control as you usually ought to aim for proper quoting when using "special" characters in strings.