清单文件示例
QDoc 会生成 example-manifest.xml 文件,其中包含所有已记录示例的信息。Qt Creator 会使用这些文件在欢迎界面中显示示例列表,并链接到它们的文档。
Manifest 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 示例添加了额外的标记,而另一个标记则通过只使用*
作为匹配字符串而应用于所有示例。
© 2025 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.