PDA

View Full Version : QtSettings and QStringList



matsukan
23rd February 2014, 21:20
Hi,

is there any way strip this

key=['5555','4444','5555']

to 555,4444,5555 ? When my program reads this settings from ini with using QSettings class it will procude a QStringList which has next items:

0 ['5555'
1 '4444'
2 '5555']

schnitzel
23rd February 2014, 22:25
are you sure that is proper ini format?
you might have to put the value after '=' in double quotes and deal with the parsing of that string yourself.
key="['5555','4444','5555']"
or prevent the '[' and ']' to go into the ini file in the first place.

Infinity
23rd February 2014, 22:50
How do you read and write the settings file (provide some code)?

anda_skoa
23rd February 2014, 22:53
Assuming you can't get the INI file to be more what you would like to have, as schitzel suggested.

Iterate over the list, use QString::section(), separator character ' and section index 1.

Cheers,
_

matsukan
24th February 2014, 20:51
ok,

I do have a project which transform a project from another language to Qt. Seems to that I have to format break in here.

thanks.