包含图片
使用图形命令可以在文档中包含图像。图片可以作为单独的段落呈现,也可以在运行文本中呈现。
\图像
\image 命令会扩展到其第一个参数指定的图像,并将其作为单独的段落居中显示。
该命令需要两个参数。第一个参数是图像文件的名称。第二个参数是对图片内容的描述,用于 HTMLalt
属性。屏幕阅读器可朗读其内容,因此强烈建议为无障碍目的使用该命令。不支持图片的浏览器(如 Lynx 文本浏览器)也可以使用它。您还可以设置usealttextastitle变量,使 QDoc 为图像生成标题属性,当用户将鼠标悬停在图像上时,图形文本浏览器通常会将其显示为工具提示。
虽然 QDoc 很宽容,但您还是应该用大括号将文件名和描述都包起来,就像这样:
\image {Bandit.png} {A Golden Retriever holding a bag of coffee in its mouth}
这种语法是最明确的语法,应该总能得到预期的结果。如果不是这样,请确保在文件名或说明后面加上换行符。如果描述参数跨多行,则需要使用大括号。如果描述用双引号封装,QDoc 会在生成输出前移除双引号。在 QDoc 的 HTML 输出中,特殊字符可能会被替换为相应的 HTML 实体代码。
/*! Qt is a C++ toolkit for cross-platform GUI application development. \image {happyguy.jpg} {Happy guy} Qt provides single-source portability across Microsoft Windows, macOS, Linux, and all major commercial Unix variants. It is also available for embedded devices. */
另请参阅\inlineimage和 \caption。
\inlineimage
\inlineimage 命令会扩展到其参数指定的图像。图像将与文本的其余部分一起内联渲染。
该命令需要两个参数。第一个参数是图像文件的名称。第二个参数是可选参数,是大括号 {} 中对图片的简单描述,相当于图片标记中的 HTML alt=""。描述用于工具提示,也可用于浏览器不支持图片的情况,如 Lynx 文本浏览器。
\inlineimage 命令最常用于列表和表格。下面是一个在列表中包含内联图像的示例:
/*! \list 1 \li \inlineimage happy.gif {Oh so happy, I am a caption!} \li \inlineimage happy.gif Oh so happy, but I'm not a caption. \endlist */
下面是在表格中包含内联图像的示例:
/*! \table \header \li Qt \li Qt Creator \row \li \inlineimage happy.gif {Oh so happy!} \li \inlineimage happy.gif Oh so happy! \row \li \inlineimage happy.gif Oh so happy! \li \inlineimage happy.gif {Oh so happy!} \endtable */
该命令还可用于在文本中插入内嵌图片。
/*! \inlineimage training.jpg {Qt Training} The Qt Programming course is offered as a five day Open Enrollment Course. The classes are open to the public. Although the course is open to anyone who wants to learn, attendees should have significant experience in C++ development to derive maximum benefit from the course. */
\caption
caption 命令为图像提供标题。
该命令将段落末尾的所有文字作为标题。尝试一下,直到达到你想要的效果。
/*! \table 100% \row \li \image windows-pushbutton.png \caption The QPushButton widget provides a command button. \li \image windows-toolbutton.png \caption The QToolButton class provides a quick-access button to commands or options, usually used inside a QToolBar. \endtable */
另请参见\image和\inlineimage
© 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.