Hi.
I'm new to QT, I found this forum very helpful, but now I have a problem that I couldn't find a solution for in old topics.
I'm trying to to save QSettings to XML, I know I have to register a new format, I did all that, I got readXMLfile and writeXMLfile functions from this post, changed them a bit and everything works just fine, except one thing.
If I want two values with same parent element names, they duplicate in XML file, let me give you an example:
the code is:
settings->setValue("themes/author/name", "arturo182");
settings->setValue("themes/author/email", "arturo182@qwerty.com");
settings->setValue("themes/author/name", "arturo182");
settings->setValue("themes/author/email", "arturo182@qwerty.com");
To copy to clipboard, switch view to plain text mode
xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<themes>
<author>
<name>arturo182</name>
</author>
</themes>
<themes>
<author>
<email>arturo182@qwerty.com</email>
</author>
</themes>
</settings>
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<themes>
<author>
<name>arturo182</name>
</author>
</themes>
<themes>
<author>
<email>arturo182@qwerty.com</email>
</author>
</themes>
</settings>
To copy to clipboard, switch view to plain text mode
and what I'm trying to achieve is:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<themes>
<author>
<name>arturo182</name>
<email>arturo182@qwerty.com</email>
</author>
</themes>
</settings>
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<themes>
<author>
<name>arturo182</name>
<email>arturo182@qwerty.com</email>
</author>
</themes>
</settings>
To copy to clipboard, switch view to plain text mode
I tried almost everything, but as I said, I'm new to QT and not sure how to fix this problem.
Maybe someone has better idea of how to achive what I want to do.
I already checked QDomDocument, QDomElement and all that, but I just love creating XML by using syntax like "parent/child/childchild".
Also it would be nice to have access to attributes like this:
setValue("themes/author[name]", "arturo182");
setValue("themes/author[name]", "arturo182");
To copy to clipboard, switch view to plain text mode
Bookmarks