PersistentSettingsReader Class

class Utils::PersistentSettingsReader

The PersistentSettingsReader class reads a QVariantMap of arbitrary, nested data structures from an XML file. More...

Header: #include <PersistentSettingsReader>

Detailed Description

Handles all string-serializable simple types and QVariantList and QVariantMap. Example:

<qtcreator>
    <data>
        <variable>ProjectExplorer.Project.ActiveTarget</variable>
        <value type="int">0</value>
    </data>
    <data>
        <variable>ProjectExplorer.Project.EditorSettings</variable>
        <valuemap type="QVariantMap">
            <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
        </valuemap>
    </data>

When parsing the structure, a parse stack of ParseValueStackEntry is used for each <data> element. ParseValueStackEntry is a variant/union of:

  • simple value
  • map
  • list

You can register string-serialize functions for custom types by registering them in the Qt Meta type system. Example:

QMetaType::registerConverter(&MyCustomType::toString);
QMetaType::registerConverter<QString, MyCustomType>(&myCustomTypeFromString);

When entering a value element ( <value> / <valuelist> , <valuemap> ), entry is pushed accordingly. When leaving the element, the QVariant-value of the entry is taken off the stack and added to the stack entry below (added to list or inserted into map). The first element of the stack is the value of the <data> element.

See also Utils::PersistentSettingsWriter.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.