Text Markup
The text formatting commands indicate how text is to be rendered.
\a (parameter marker)
The \a command tells QDoc the next word is a formal parameter name.
A warning is emitted when a formal parameter is not documented or is misspelled, so when you document a function you should mention each formal parameter by name in the function description, preceded by the \a command. The parameter name is then rendered in italics.
The formal parameter name may be enclosed between curly brackets, but that isn't required.
\c (code font)
The \c command is used for rendering variable names, user-defined class names, and C++ keywords (for example, int
and for
) in the code font.
The command renders its argument using a monospace font. If the text to be rendered in the code font contains spaces, enclose the entire text in curly brackets:
\c {QLineEdit::QLineEdit(const QString &contents, QWidget *parent) : QWidget(parent)}
The \c command accepts the special character \
within its argument, which renders it as a normal character. So if you want to use nested commands, you must use the teletype (\tt) command instead.
\details (collapsible)
The \details and \enddetails commands generates a collapsible <details> element with a <summary> to control the hidden/visible state.
When generating HTML output, use the \details and \enddetails commands to generate a collapsible <details>
HTML element. The command takes an optional summary string enclosed in curly braces. This optional argument specifies a visible heading for the details.
For example, with the following input:
/*! \details {QDoc details} \note You're looking at detailed information. \enddetails */
If QDoc is generating HTML, it will translate these commands to:
<summary>QDoc details</summary><div class="admonition note"><p><b>Note: </b>You're looking at detailed information.</p></div>
QDoc renders this as:
QDoc details
Note: You're looking at detailed information.
For any other output format, QDoc generates the contents as a normal paragraph, ignoring the summary string. This command was introduced to QDoc in Qt6.6.
\div
The \div and \enddiv commands delimit a large or small block of text (which may include other QDoc commands) to which special formatting attributes should be applied.
An argument must be provided in curly braces, as in the QDoc comment shown below. The argument is not interpreted but is used as attribute(s) of the tag that is output by QDoc.
For example, we might want to render an inline image so that it floats to the right of the current block of text:
/*! \div {class="float-right"} \inlineimage qml-column.png \enddiv */
If QDoc is generating HTML, it will translate these commands to:
<div class="float-right"><p><img src="images/qml-column.png" /></p></div>
For HTML, the attribute value float-right then will refer to a clause in the style.css file, which in this case could be:
div.float-right { float: right; margin-left: 2em }
Note: Note that the \div command can be nested.
Below you can find an example taken from the index.qdoc file used to generate index.html for Qt 4.7:
\div {class="indexbox guide"} \div {class="heading"} Qt Developer Guide \enddiv \div {class="indexboxcont indexboxbar"} \div {class="section indexIcon"} \emptyspan \enddiv \div {class="section"} Qt is a cross-platform application and UI framework. Using Qt, you can write web-enabled applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code. \enddiv \div {class="section sectionlist"} \list \li \l{Getting Started} \li \l{Installation} {Installation} \li \l{how-to-learn-qt.html} {How to learn Qt} \li \l{tutorials.html} {Tutorials} \li \l{Qt Examples} {Examples} \li \l{qt4-7-intro.html} {What's new in Qt 4.7} \endlist \enddiv \enddiv \enddiv
When all the class attribute values are defined as they are in the style.css file that is used for rendering the Qt documentation, the above example is rendered as:
Qt Developer Guide
See also \span.
\span
The \span command applies special formatting to a small block of text.
Two arguments must be provided, each argument in curly braces, as shown in the QDoc comment below. The first argument is not interpreted, but specifies the formatting attribute(s) of the tag output by QDoc. The second argument is the text to be rendered with the special formatting attributes.
For example, we might want to render the first word of each element in a numeric list in blue.
/*! Global variables with complex types: \list 1 \li \span {class="variableName"} {mutableComplex1} in globals.cpp at line 14 \li \span {class="variableName"} {mutableComplex2} in globals.cpp at line 15 \li \span {class="variableName"} {constComplex1} in globals.cpp at line 16 \li \span {class="variableName"} {constComplex2} in globals.cpp at line 17 \endlist */
Class variableName refers to a clause in your style.css.
.variableName { font-family: courier; color: blue }
Using the variableName clause shown above, the example is rendered as:
Global variables with complex types:
- mutableComplex1 in globals.cpp at line 14
- mutableComplex2 in globals.cpp at line 15
- constComplex1 in globals.cpp at line 16
- constComplex2 in globals.cpp at line 17
Note: The span command does not cause a new paragraph to be started.
See also \div.
\tm (trademark)
The \tm command indicates that its argument is a trademark. QDoc appends a trademark symbol `™` to the first occurrence of the argument when generating a page.
In the project's configuration, the navigation.trademarkspage
variable is used for defining a title of a page that contains trademark-related documentation.
navigation.trademarkspage = Trademarks
If set, each occurrence of the trademark symbol also links to the trademarks page.
Note: In section titles, the \tm command is ignored and its argument rendered as-is.
See also \section1 and navigation
.
\tt (teletype font)
The \tt command renders its argument in a monospace font. This command behaves just like the \c command, except that \tt allows you to nest QDoc commands within the argument (e.g. \e, \b and \underline).
/*! After having populated the main container with child widgets, \c setupUi() scans the main container's list of slots for names with the form \tt{on_\e{objectName}_\e{signalName}().} */
If the text to be rendered in the code font contains spaces, enclose the entire text in curly brackets.
\tt {QLineEdit::QLineEdit(const QString &contents, QWidget *parent) :QWidget(parent)}
See also \c.
\b
The \b command renders its argument in bold font. This command used to be called \bold.
/*! This is regular text; \b {this text is rendered using the \\b command}. */
\br
The \br command forces a line break.
\e (emphasis, italics)
The \e command renders its argument in a special font, normally italics. This command used to be called \i, which is now deprecated.
If the argument contains spaces or other punctuation, enclose the argument in curly brackets.
/*! Here, we render \e {a few words} in italics. */
If you want to use other QDoc commands within an argument that contains spaces, you always need to enclose the argument in braces. But QDoc is smart enough to count parentheses, so you don't need braces in cases like this:
/*! An argument can sometimes contain whitespaces, for example: \e QPushButton(tr("A Brand New Button")) */
Finally, trailing punctuation is not included in an argument, nor is "'s".
\sub
The \sub command renders its argument lower than the baseline of the regular text, using a smaller font.
/*! Definition (Range): Consider the sequence {x\sub n}\sub {n > 1} . The set {x\sub 2, x\sub 3, x\sub 4, ...} = {x\sub n ; n = 2, 3, 4, ...} is called the range of the sequence. */
If the argument contains spaces or other punctuation, enclose the argument in curly brackets.
\sup
The \sup command renders its argument higher than the baseline of the regular text, using a smaller font.
/*! The series 1 + a + a\sup 2 + a\sup 3 + a\sup 4 + ... is called the \i {geometric series}. */
If the argument contains spaces or other punctuation, enclose the argument in curly brackets.
\uicontrol
The \uicontrol command is used to mark content as being used for UI control elements. When using HTML, the output is rendered in bold.
See also \b.
\underline
The \underline command renders its argument underlined.
/*! The \underline {F}ile menu gives the users the possibility to edit an existing file, or save a new or modified file, and exit the application. */
If the argument contains spaces or other punctuation, enclose the argument in curly brackets.
\\ (double backslash)
The sequence \\ expands to a single backslash.
QDoc commands always start with a single backslash. To display a single backslash in the text, you must type two backslashes. If you want to display two backslashes, you must type four.
/*! The \\\\ command is useful if you want a backslash to appear verbatim, for example, writing C:\\windows\\home\\. */
However, if you want your text to appear in a monospace font as well, you can use the \c command instead, which accepts and renders the backslash as any other character. For example:
/*! The \\c command is useful if you want a backslash to appear verbatim, and the word that contains it written in a monospace font, like this: \c {C:\windows\home\}. */
-- (en dash)
QDoc renders double hyphens as an en dash. QDoc markup commands designed to make their input appear verbatim—such as the \c command—won't replace the double hyphens with an en dash character. For example:
/*! The \\c command -- useful if you want text in a monospace font -- is well documented. */
However, other commands may require that the hyphens are escaped to ensure QDoc renders the output as expected. For example;
/*! This \l {endash-sequence}{link to the -- (endash) sequence} isn't escaped and QDoc therefore renders an endash in the link text. However, the escaped \l {endash-sequence}{link to the \-- (endash) sequence} renders both hyphens as intended. */
See also --- (em dash).
--- (em dash)
QDoc renders triple hyphens as an en dash. QDoc markup commands designed to make their input appear verbatim—such as the \c command—won't replace the triple hyphens with an en dash character. For example:
/*! The \\c command---useful when you want text to be rendered verbatim---is well documented. */
However, other commands may require that the hyphens are escaped to ensure QDoc renders the output as expected. For example;
/*! This \l {emdash-sequence}{link to the --- (emdash) sequence} isn't escaped and QDoc therefore renders an emdash in the link text. However, the escaped \l {emdash-sequence}{link to the -\-- (emdash) sequence} renders both hyphens as intended. */
Note: The escaped control sequence in this example is for the en dash. This avoids a hyphen followed by an en dash in the output.
See also -- (en dash).