本页内容

标签式内容

使用以下宏可创建带有标签的 HTML标签组,这些标签组包含内容相似或互为替代的内容。例如,您可以展示不同编程语言的代码片段。

使用标签页宏

\tab {name}{tab-id}{title}{checked}
\tabcontent {tab-id}
  content
\endtabcontent

注意:这些 宏仅适用于在线模板和 DocBook,因此若要使离线帮助也能获得良好效果,通常需要使用条件文本。

例如,若要在标签页中显示 CMake 和 qmake 构建系统的说明:

\if defined(onlinedocs)
  \tab {build-qt-app}{tab-cmake}{CMake}{checked}
  \tab {build-qt-app}{tab-qmake}{qmake}{}
  \tabcontent {tab-cmake}
\else
  \section1 Using CMake
\endif
  CMake-specific instructions go here
\if defined(onlinedocs)
  \endtabcontent
  \tabcontent {tab-qmake}
\else
  \section1 Using qmake
\endif
  qmake-specific instructions go here
\if defined(onlinedocs)
  \endtabcontent
\endif

\tab

\tab {name}{tab-id}{title}{checked}

指定一个标签组中的标签,并为其指定名称、ID、标题和默认状态。

请使用唯一名称来指定哪些标签页属于某个标签组。也就是说,组中的所有标签页都应具有相同的名称。为了区分这些标签页,请在组内为每个标签页分配一个唯一的标签页 ID。将此标签页 ID作为\tabcontent 宏的值,即可向该标签页添加内容。

“checked”参数用于在HTML页面加载时默认选中该标签页。对于初始状态为隐藏的标签页,请传递一个空参数 {}。

\tabcontent

\tabcontent {tab-id}

向您指定的tab-id对应的标签页中添加内容。

\endtabcontent

标记以\tabcontent 开头的标签页内容的结尾。

另请参 阅“宏”。

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