示例清单文件
QDoc 会生成 example-manifest.xml 文件,其中包含所有已记录示例的相关信息。Qt Creator 会使用这些文件在其欢迎界面中显示示例列表,并链接至相应的文档。
清单 XML 结构
一个清单文件的结构如下:
<?xml version="1.0" encoding="UTF-8"?>
<instructionals module="QtGui">
<examples>
<example
name="Analog Clock Window"
docUrl="qthelp://org.qt-project.qtgui.502/qtgui/analogclock.html"
projectPath="gui/analogclock/analogclock.pro"
imageUrl="qthelp://org.qt-project.qtgui.502/qtgui/images/analogclock-window.png">
<description><![CDATA[The Analog Clock Window example shows how
to draw the contents of a custom window.]]></description>
<tags>analog,clock,window</tags>
<fileToOpen>gui/analogclock/main.cpp</fileToOpen>
</example>
...
</examples>
</instructionals>每个<example> 元素包含有关名称、描述、项目文件和文档位置的信息,以及与该示例相关的标签列表。
清单元数据
可以通过manifestmeta 配置命令,为清单文件添加额外的元内容——即为选定的示例添加额外的属性和标签。
元内容的一个应用场景是突出显示若干重要的示例。另一个应用场景是通过为特定类别的示例添加相关关键词作为标签,从而改进搜索功能。
应用元内容的示例是通过一个或多个过滤器来指定的。示例与过滤器的匹配基于名称进行,每个示例名称前都带有模块名称和一个斜杠。系统支持简单的通配符匹配;通过在末尾使用* ,可以用一个字符串匹配多个示例。
示例:
manifestmeta.filters = highlighted sql webkit global
manifestmeta.highlighted.names = "QtGui/Analog Clock Window" \
"QtWidgets/Analog Clock"
manifestmeta.highlighted.attributes = isHighlighted:true
manifestmeta.sql.names = "QtSql/*"
manifestmeta.sql.tags = database,sql
manifestmeta.webkit.names = "QtWebKitExamples/*"
manifestmeta.webkit.tags = webkit
manifestmeta.global.names = *
manifestmeta.global.tags = qt6在上例中,两个示例都添加了isHighlighted 属性。如果省略属性值,QDoc将默认使用字符串true 。针对Qt WebKit和Qt SQL 示例添加了额外标签,而通过仅使用* 作为匹配字符串,则将另一个标签应用于所有示例。
© 2026 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.