表格和列表
这些命令可用于创建列表和表格。列表将作为单独的段落显示,并左对齐。表格将作为单独的段落显示,并居中对齐。表格的宽度取决于其内容的宽度。
\table
\table 和\endtable 命令用于限定表格的内容范围。
该命令接受一个参数,用于指定表格宽度占页面宽度的百分比:
/*!
\table 100%
...
\endtable
*/上述代码可确保表格将填满所有可用空间。如果表格宽度小于 100%,则表格将在生成的文档中居中显示。
表格可以包含表头、行和列。一行以 \row 命令,并由单元格组成,每个单元格均以 \li 命令。此外还有 \header 命令,它是一种具有特殊格式的特殊行。
/*!
\table
\header
\li Qt Core Feature
\li Brief Description
\row
\li \l {Signal and Slots}
\li Signals and slots are used for communication
between objects.
\row
\li \l {Layout Management}
\li The Qt layout system provides a simple
and powerful way of specifying the layout
of child widgets.
\row
\li \l {Drag and Drop}
\li Drag and drop provides a simple visual
mechanism which users can use to transfer
information between and within applications.
\endtable
*/您还可以让单元格横跨多行和多列。例如:
/*!
\table
\header
\li {3,1} This header cell spans three columns,
but only one row.
\row
\li {2, 1} This table cell spans two columns,
but only one row
\li {1, 2} This table cell spans only one column,
but two rows.
\row
\li A regular table cell
\li A regular table cell
\endtable
*/\header
\header 命令表示以下表格单元格是当前表格的列标题。
该命令仅可在\table...\endtable命令范围内使用。一个表头可以包含多个单元格。单元格通过 \li 命令创建。
表头单元格中的文本在表单元格内居中显示,并以粗体字体呈现。
/*!
\table
\header
\li Qt Core Feature
\li Brief Description
\row
\li \l {Signal and Slots}
\li Signals and slots are used for communication
between objects.
\endtable
*/\row
\row 命令会在表格中开始一行。属于新行的\li 项将紧跟在\row 之后。
该命令只能在\table...\endtable命令范围内使用。一行可以包含多个单元格。单元格可通过 \li 命令创建。
每行单元格的背景色在两种灰色调之间交替显示,便于区分不同行。单元格内容左对齐。
/*!
\table
\header
\li Qt Core Feature
\li Brief Description
\row
\li \l {Signal and Slots}
\li Signals and slots are used for communication
between objects.
\row
\li \l {Layout Management}
\li The Qt layout system provides a simple
and powerful way of specifying the layout
of child widgets.
\row
\li \l {Drag and Drop}
\li Drag and drop provides a simple visual
mechanism which users can use to transfer
information between and within applications.
\endtable
*/\value
\value 命令用于开始编写C++枚举项的文档。
该命令的第一个参数是值名。值名前可选地以方括号括起的since子句开头。值名之后是值的描述。描述以下一行空行或\value 为结尾。这些参数将以表格形式呈现。
注意:若要在 `\value ` 描述中插入图片,请使用 \inlineimage 命令。
如果没有“since”子句,\value 命令可能如下所示:
包含since子句的相同命令则如下所示:
文档将位于相关的类、头文件或命名空间的文档中。有关示例,请参阅 \enum 文档中的示例。
注意:自 Qt 5.4 起,\value 命令也可在 \enum 主题之外使用。在此情况下,QDoc 会渲染一个两栏表格,列出常量名称(直接取自第一个参数)及其描述。例如,这可用于 \qmlproperty 主题中,用于记录 QML 枚举属性的有效值。
另请参阅 \enum 以及 \omitvalue。
\omitvalue
\omitvalue 命令可将C++枚举项从文档中排除。
该命令唯一的必填参数是将被省略的枚举项的名称。如果该枚举项后面跟有一行描述,该描述也会被省略。
请参阅 \enum 文档中的示例。
\list
\list 和\endlist 命令用于限定项目列表。
使用 \li 命令创建。列表总是包含一个或多个项目。列表可以嵌套。例如:
/*!
\list
\li Qt Reference Documentation: Getting Started
\list
\li How to Learn Qt
\li Installation
\list
\li Qt/X11
\li Qt/Windows
\li Qt/Mac
\li Qt/Embedded
\endlist
\li Tutorial and Examples
\endlist
\endlist
*/\list 命令接受一个可选参数,用于为列表项提供不同的外观样式。
/*!
\list
\li How to Learn Qt
\li Installation
\li Tutorial and Examples
\endlist
*/如果将“A”作为参数传递给\list 命令,项目符号将被按字母顺序排列的字符所替换:
- 如何学习 Qt
- 安装
- 教程与示例
如果你将“A”替换为“1”,列表项将按升序编号:
- 如何学习 Qt
- 安装
- 教程与示例
如果将“i”作为参数,项目符号将替换为罗马数字:
- 如何学习 Qt
- 安装
- 教程与示例
最后,如果你将“I”作为可选参数提供,列表项就会以罗马数字显示,且按升序排列:
- 如何学习 Qt
- 安装
- 教程与示例
您还可以通过指定起始位置的字符或数字,让代码列表从任意位置开始。例如:
/*!
\list G
\li How to Learn Qt
\li Installation
\li Tutorial and Examples
\endlist
*/另请参阅 \li。
\li (表格单元格、列表项)
\li 命令用于标记表格单元格或列表项。该命令仅适用于表格和列表。
它将所有内容都视为其参数,直到下一个\li 命令,直到下一个 \endtable,或 \endlist 命令为止。参见 \table 和 \list 中的示例。
如果在表格中使用该命令,您还可以指定该元素应跨越多少行或列。
/*!
\table
\header
\li {3,1} This header cell spans three columns
but only one row.
\row
\li {2, 1} This table item spans two columns
but only one row
\li {1, 2} This table item spans only one column,
but two rows.
\row
\li A regular table item
\li A regular table item
\endtable
*/如果未指定,该项目将横跨一列一行。
© 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.