Utils::PersistentSettingsReader Class
class Utils::PersistentSettingsReaderPersistentSettingsReader 类用于从 XML 文件中读取包含任意嵌套数据结构的“QVariantMap ”。更多内容...
| Header: | #include <PersistentSettingsReader> |
详细说明
支持所有可字符串序列化的简单类型,以及 `QVariantList ` 和 `QVariantMap`。示例:
<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>
在解析该结构时,每个 <data> 元素都会使用一个由 ParseValueStackEntry 组成的解析堆栈。ParseValueStackEntry 是一个由以下元素组成的变体/联合体:
- 简单值
- 映射
- 列表
您可以通过在 Qt Meta 类型系统中注册自定义类型,为其注册字符串序列化函数。示例:
QMetaType::registerConverter(&MyCustomType::toString); QMetaType::registerConverter<QString, MyCustomType>(&myCustomTypeFromString);
当进入值元素(<value> /<valuelist> /<valuemap> )时,会相应地将条目压入栈中。当离开该元素时,会从栈中弹出该条目的QVariant 值,并将其添加到下方的栈条目中(添加到列表中或插入到映射中)。栈中的第一个元素即为<data>元素的值。
Copyright © The Qt Company Ltd. and other contributors. 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.