本页内容

文档结构

文档结构化命令用于将文档划分为各个章节。QDoc 支持四级章节:\section1 、\section2 、\section3 和\section4 。这些章节命令对应于大纲中常用的“章节”、“子章节”等传统术语。

章节命令

通常,文档结构化命令将其后直至第一个换行符之前的所有内容视为其参数。该参数将作为该单元的标题显示。如果标题需要分多行显示,请确保每行(最后一行除外)以反斜杠结尾。

QDoc 中共有四个章节级别:\section1 、\section2 、\section3 和\section4 。它们分别对应传统的章节、子章节、子子章节和子子子章节。

各章节单元的排列顺序有严格规定:

section1
      |
      section2
             |
             section3
                    |
                    section4

使用章节时,第一个章节命令应为section1 。

/*!
    \section1 Basic Qt

    This is the first section.


        \section2 Getting Started

        This is the first subsection.


            \section3 Hello Qt

            This is the first subsubsection.


            \section3 Making Connections

            This is the second subsubsection.


            \section3 Using the Reference Documentation

            This is the third subsubsection.


        \section2 Creating Dialogs

        This is the second subsection.


            \section3 Subclassing QDialog

            This is the first subsubsection.

            ...


    \section1 Intermediate Qt

    This is the second section.


        \section2 Layout Management

        This is the second section's first subsection.


            \section3 Basic Layouts

            This is the first subsubsection.

        ...
*/

每个章节都是文档中的一个逻辑单元。章节标题会显示在自动生成的目录中,该目录通常位于页面的右上角。

\section1

\section1 命令用于开始一个新章节。

有关各种章节单元、命令参数及渲染方式的说明,请参阅“章节命令”部分。

\section2

\section2 命令用于开始一个新章节。

有关各种章节单位、命令参数和渲染效果的说明,请参阅“章节命令”部分。

\section3

\section3 命令用于开始一个新章节。

有关各种章节单位、命令参数及渲染效果的说明,请参阅“章节命令”部分。

\section4

\section4 命令用于开始一个新章节。

有关各种章节单位、命令参数及渲染效果的说明,请参见“章节命令”部分。

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