- Extending Qt Creator Manual
- QtCreator
- PersistentSettingsReader
- Extending Qt Creator Manual 17.0.2

# Utils::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.