本页内容

文档导航

导航命令用于将文档中的页面按有意义的顺序链接起来。下面是一系列 QDoc 注释,展示了导航命令的典型用法。

示例

 /*!
     \page basicqt.html
     \nextpage Getting Started

     \indexpage Index
     \startpage Basic Qt

     \title Basic Qt

     The Qt toolkit is a C++ class library and a set of tools for
     building multiplatform GUI programs using a "write once,
     compile anywhere approach".

     Table of contents:

     \list
     \li \l {Getting Started}
     \li \l {Creating Dialogs}
     \li \l {Creating Main Windows}
     \endlist
 */

 /*!
    \page gettingstarted.html
    \previouspage Basic Qt
    \nextpage Creating Dialogs

    \indexpage Index
    \startpage Basic Qt

    \title Getting Started

    This chapter shows how to combine basic C++ with the
    functionality provided by Qt to create a few small graphical
    interface (GUI) applications.
*/

/*!
    \page creatingdialogs.html
    \previouspage Getting Started

    \indexpage Index
    \startpage Basic Qt

    \title Creating Dialogs

    This chapter will teach you how to create dialog boxes using Qt.
*/

/*!
    \page index.html

    \indexpage Index
    \startpage Basic Qt

    \title Index

    \list
        \li \l {Basic Qt}
        \li \l {Creating Dialogs}
        \li \l {Getting Started}
    \endlist
*/

\startpage 该命令会创建一个链接,指向作者希望作为多页文档首页的页面。

该链接会包含在生成的 HTML 源代码中,但不会对文档产生任何视觉效果:

<head>
    ...
    <link rel="start" href="basicqt.html" />
    ...
</head>

命令

\previouspage

\previouspage 命令将当前页面与序列中的上一页建立链接。该命令有两个参数,每个参数都用大括号括起来:第一个是链接目标(上一页的标题),第二个是链接文本。如果页面的标题与链接文本相同,则可以省略第二个参数。

该命令必须单独位于一行上。

\nextpage

\nextpage 命令将当前页面链接到序列中的下一页。该命令的语法和参数约定与 \previouspage 命令相同。

\startpage

\startpage 命令用于指定一组页面的第一页。该命令必须独占一行,其唯一参数是第一个文档的标题。

QDoc 将生成一个指向起始页面的链接,并将其包含在生成的 HTML 文件中,但这不会对文档产生任何视觉效果。生成的链接类型会告知浏览器和搜索引擎,作者将哪份文档视为该文档集合的起点。

\toc

\toc 和\endtoc 命令用于指定该命令所在主题的子主题(页面)列表。系统会根据每个主题中的目录条目,为整个文档项目生成一个目录(TOC)层次结构。

在\toc..\endtoc 代码块内,请使用 \tocentry 命令按标题指定子主题。与 \l (link) 命令一样,\tocentry 接受一个可选的第二个参数,用于指定在生成的目录条目中用户可见的标题。

/*!
    \page index.html
    \title Qt
    ...
    \toc
        \tocentry {Introduction to Qt} {Introduction}
        \tocentry {What's new in Qt} {What's new}
        \tocentry {Getting started}
    \endtoc
*/

\toc命令不能嵌套。不过,每个子主题都可以指定自己的目录条目。一个主题只能使用一个\toc 命令。

QDoc 将生成的目录结构以 XML 格式写入<project>_toc.xml文件中。

注意: 根主题 (索引或登陆页)必须在项目配置中通过navigation.landingpage 或navigation.homepage 指定。请参阅 navigation 以获取更多信息。

\toc 命令是随 Qt 6.11 一起引入 QDoc 的。

另请参阅 \tocentry。

\tocentry

将子主题(页面)指定为目录中的条目。只能在\toc 和\endtoc 命令对之间使用。

\tocentry 命令是在Qt 6.11中引入QDoc的。

另请参阅 \toc。

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