创建帮助项目文件

概述

Qt Assistant QDoc 是一个用于管理 Qt 文档的系统,它要求 QDoc 生成文件清单。

QDoc 允许使用配置变量来指定在其生成的每个文档集中使用哪些页面。这些变量被指定为qhp 变量的子变量,每个文件集都使用唯一标识符作为子变量声明。

例如,Qt Quick 文档集的配置文件将文档集的相关信息指定为带有qhp.QtQuick 前缀的子变量:

qhp.projects = QtQuick

qhp.QtQuick.file                = qtquick.qhp
qhp.QtQuick.namespace           = org.qt-project.qtquick.$QT_VERSION_TAG
qhp.QtQuick.virtualFolder       = qtquick
qhp.QtQuick.indexTitle          = Qt Quick
qhp.QtQuick.indexRoot           =

qhp.QtQuick.subprojects         = qmltypes classes examples

qhp.QtQuick.subprojects.qmltypes.title = QML Types
qhp.QtQuick.subprojects.qmltypes.indexTitle = Qt Quick QML Types
qhp.QtQuick.subprojects.qmltypes.selectors = qmlclass
qhp.QtQuick.subprojects.qmltypes.sortPages = true

qhp.QtQuick.subprojects.classes.title = Classes
qhp.QtQuick.subprojects.classes.title = C++ Classes
qhp.QtQuick.subprojects.classes.indexTitle = Qt Quick C++ Classes
qhp.QtQuick.subprojects.classes.selectors = class fake:headerfile
qhp.QtQuick.subprojects.classes.sortPages = true

qhp.QtQuick.subprojects.examples.title = Examples
qhp.QtQuick.subprojects.examples.indexTitle = Qt Quick Examples and Tutorials
qhp.QtQuick.subprojects.examples.selectors = fake:example

文档集可能包括一个或多个子项目,这些子项目会以title 指定的名称添加到目录中。indexTitle 提到的文档中的页面作为子项目的索引页。子项目下要列出的页面类型由selectors 指定。如果sortPages 设置为true ,则条目按字母顺序排序。

使用选择器

selectors 属性可指定子项目目录条目下列出的页面类型。可以列出多个选择器,以空格分隔。

注意: 如果子项目未定义selectors 属性,则默认包含项目中的所有页面。

选择器说明
namespace名称空间
class
qmltypeQML 类型
qmlclassqmltype.C++ 模块或具有指定名称的模块成员的别名。
module[:name]具有指定名称的 C++ 模块或模块成员。
qmlmodule[:name]具有指定名称的 QML 模块或模块成员。
doc[:subtype]具有指定subtype 的文档页面。多个子类型可以逗号分隔的列表形式列出。
fakedoc 的别名。
group[:groupname]使用\ingroupgroupname 命令添加的指定组成员的文档页面。多个组名可以逗号分隔的列表形式列出。(在 QDoc 5.6 中引入)。
none不选择任何内容;只生成指向indexTitle 的链接。(在 QDoc 6.9 中引入)。

doc 选择器的可用子类型:

子类型说明
example示例
headerfile头文件
page使用\page命令定义的文档页面。

例如,以下配置将选择包含\ingroup tutorials 命令的示例页面和页面:

qhp.QtQuickControls.subprojects = examples
qhp.QtQuickControls.subprojects.examples.title = Examples and Tutorials
qhp.QtQuickControls.subprojects.examples.indexTitle = Qt Quick Controls Examples
qhp.QtQuickControls.subprojects.examples.selectors = doc:example group:tutorials
qhp.QtQuickControls.subprojects.examples.sortPages = true

添加目录

要为手册创建目录,请创建一个带有type 属性的子项目,并将其设置为manual 。由indexTitle 属性引用的文档页面必须包含一个链接列表,作为整个手册的目录。QDoc 将利用该列表中的信息,为子项目创建一个目录。

例如,Qt Creator 的配置文件只为其文档定义了一个子项目,包括单本手册中的所有文档:

qhp.QtCreator.subprojects = manual
qhp.QtCreator.subprojects.manual.title = Qt Creator Manual
qhp.QtCreator.subprojects.manual.indexTitle = Qt Creator Manual
qhp.QtCreator.subprojects.manual.type = manual

在此示例中,标题为"Qt Creator Manual "的页面包含一个嵌套的链接列表,指向Qt Assistant 的 "内容 "选项卡中重复的文档页面。

© 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.