It doesn't matter, make a copy, and edit the copy and try that.
If you then can get the value, then at least you know what the problem is, and you know that you either have to subclass QSettings to allow that kind of lines, or do the reading your self.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Post your code.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Qt Code:
set.beginGroup(grpName); CnaWindow *win = new CnaWindow(); win->title= set.value("Title").toString(); win->number= set.value("Number").toInt(); win->position= set.value("Position").toString(); set.endGroup();To copy to clipboard, switch view to plain text mode
and here's a part of the ini file
[WINDOW_14]
Title=Balken
Type=2
Comment=Balken-Fenster
Number=14
Position=0, 50, 50, 450, 100 ;cmd, x, y, w, h
DisplayMask=32
JointIndex=4294967295
Grid=1
RelMode=0
VerMode=0
ShowLegend=1
LegendPixWidth=66
YValue=0
ObjectMode=0
AxisWidth=0
AxisHeight=0
SigDispMode=2
LegendPos=2
LegendHeight=0
LegendScrollPos=0
AxisScrollPos=6594188
ShowSignalComments=1
MaximizeToPage=0, 0, 0, 0 ;x, y, w, h
Hmm...
What does "contains" return:
Qt Code:
set.beginGroup(grpName); CnaWindow *win = new CnaWindow(); win->title= set.value("Title").toString(); bool bContains = set.contains("Number"); win->number= set.value("Number").toInt(); bContains = set.contains("Position"); win->position= set.value("Position").toString(); set.endGroup();To copy to clipboard, switch view to plain text mode
And, do you get a string if you change the value of "Position" to some normal string:
Position=test
Also, try this:
Qt Code:
To copy to clipboard, switch view to plain text mode
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
'contains' will only check if that string is contained in that group
yeap, i do get the normal string. i'm just wondering why something like '0, 0, 2, 4' can't be treated like a normal string. even without the spaces in between
and 'set.childKeys' basically returns 'Title', 'Type', 'Comment', all the strings that appear before the '=' in each line
I know. But I wanted to make sure that "Position" is seen as part of the group.'contains' will only check if that string is contained in that group
I don't know, to answer that you can look in the QSettings code.i'm just wondering why something like '0, 0, 2, 4' can't be treated like a normal string. even without the spaces in between
My guess is, that QSettings will read a line until it encounters some sort of what it considers to be an end of line, maybe ';' or maybe it only looks for alpha numerics, so the next ',' stops it...
At least you know what the problem is, that usually is half of the solution.
Now you can subclass QSettings, and adjust it to handle such lines too.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Amm... you code it?
Or I don't understand your question.
Look in to QSettings to see what it does when you call value().
Step through, and see what makes it return and not read the line.
In your subclass then, introduce code that will allow dealing with such lines as the one you have.
Another options is to not use QSettings at all, but write your own class for it.
Since you have rather a simple case (each key is the start of a line, and ends with '=', and value is everything until the end of the line) this should be rather easy to implement.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
gye325 (20th July 2011)
I tried with several string values,
when the string contains comma ',', semicolon ';' or equal '=' character, you have to "quote" the string
this
worksQt Code:
Position="0, 50, 50, 450, 100 ;cmd, x, y, w, h"To copy to clipboard, switch view to plain text mode
A camel can go 14 days without drink,
I can't!!!
Yes, but as he said, he can't change the ini file...
He will have to change the way QSettings deals with ',' ';' and '=' mamely, only stop on \r\n.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Probably he have to use QSettings::registerFormat() in order to create a "special" INI parser.
QSettings has not virtual methods or properties to access the INI parser
Last edited by mcosta; 20th July 2011 at 16:41. Reason: updated contents
A camel can go 14 days without drink,
I can't!!!
Yes, this looks like a good way to go.Probably he have to use QSettings::registerFormat() in order to create a "special" INI parser
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks