[SOLVED]QSettings does not return strings containing commas correctly
I am using the QSettings object to read an IniFormat file. I find that it will not return the correct string when commas are present. For example:
When something like...
is read, the result of doing
would be "1". everything after the first comma is ignored.
Can anyone please clarify if this is this the normal behaviour?
I cannot find any mention of such behaviour in the documentation. Any suggestions as to to what one might do to work around this. Unfortunately I cannot change the contents of the INI file.
Actually, it would be more precise to say that this appears to be related to the fact that the string is not enclosed in quotes in the INI file.
When there are Quotes around the string "1,2,3" it reads it fine otherwise it does not.
Again, unfortunately I cannot change the way the strings are written in the INI file is written.
I guess this is a candidate for writing my own read and write functions for this??
Does anyone have any other suggestions?
What type does the variant returned from QSettings::value() give you? I would not be surprised it is a list of some sort. That would enable doing something like:
to get your string including the comma's back. Note that any white space in there would be lost though.
Thank you Andre,
That was a very useful suggestion. Works like a charm.
Im also having same issue, but in different place. I want to create a *.desktop file. in that file my group title was "Desktop Entry", after creating file and i saw in edit mode, group title was seems to like [Desktop Entry]. wats wrong with ma code.. this is my code...
@ QSettings* settings = new QSettings(QDir::currentPath() + "/my_config_file.desktop", QSettings::IniFormat);
settings->beginGroup("Desktop Entry"); // Title of group