Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdoc-manual-markupcmds.qdoc
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page 03-qdoc-commands-markup.html
6 \previouspage Naming Things
7 \nextpage Macros
8
9 \title Markup Commands
10
11 The markup commands indicate the generated documentation's visual
12 appearance and logical structure.
13
14 \list
15 \li \l {a-command} {\\a}
16 \li \l {annotatedlist-command} {\\annotatedlist}
17 \li \l {b-command} {\\b}
18 \li \l {badcode-command} {\\badcode}
19 \li \l {b-command} {\\bold} (deprecated, use \\b)
20 \li \l {br-command} {\\br}
21 \li \l {brief-command} {\\brief}
22 \li \l {c-command} {\\c}
23 \li \l {caption-command} {\\caption}
24 \li \l {code-command} {\\code}
25 \li \l {codeline-command} {\\codeline}
26 \li \l {details-command} {\\details}
27 \li \l {div-command} {\\div}
28 \li \l {dots-command} {\\dots}
29 \li \l {e-command} {\\e}
30 \li \l {else-command} {\\else}
31 \li \l {endif-command} {\\endif}
32 \li \l {generatelist-command} {\\generatelist}
33 \li \l {header-command} {\\header}
34 \li \l {e-command} {\\i} (deprecated, use \\e)
35 \li \l {if-command} {\\if}
36 \li \l {image-command} {\\image}
37 \li \l {include-command} {\\include}
38 \li \l {inlineimage-command} {\\inlineimage}
39 \li \l {keyword-command} {\\keyword}
40 \li \l {l-command} {\\l}
41 \li \l {legalese-command} {\\legalese}
42 \li \l {li-command} {\\li}
43 \li \l {list-command} {\\list}
44 \li \l {meta-command} {\\meta}
45 \li \l {noautolist-command} {\\noautolist}
46 \li \l {li-command} {\\o} (deprecated, use \\li)
47 \li \l {note-command} {\\note}
48 \li \l {notranslate-command} {\\notranslate}
49 \li \l {omit-command} {\\omit}
50 \li \l {printline-command} {\\printline}
51 \li \l {printto-command} {\\printto}
52 \li \l {printuntil-command} {\\printuntil}
53 \li \l {qml-command}{\\qml}
54 \li \l {quotation-command} {\\quotation}
55 \li \l {quotefile-command} {\\quotefile}
56 \li \l {quotefromfile-command} {\\quotefromfile}
57 \li \l {raw-command} {\\raw}
58 \li \l {row-command} {\\row}
59 \li \l {sa-command} {\\sa}
60 \li \l {sectionOne-command} {\\section1}
61 \li \l {sectionTwo-command} {\\section2}
62 \li \l {sectionThree-command} {\\section3}
63 \li \l {sectionFour-command} {\\section4}
64 \li \l {sincelist-command} {\\sincelist}
65 \li \l {skipline-command} {\\skipline}
66 \li \l {skipto-command} {\\skipto}
67 \li \l {skipuntil-command} {\\skipuntil}
68 \li \l {snippet-command} {\\snippet}
69 \li \l {span-command} {\\span}
70 \li \l {sub-command} {\\sub}
71 \li \l {sup-command} {\\sup}
72 \li \l {table-command} {\\table}
73 \li \l {target-command} {\\target}
74 \li \qdoccmd tm
75 \li \l {tt-command} {\\tt}
76 \li \l {uicontrol-command} {\\uicontrol}
77 \li \l {underline-command} {\\underline}
78 \li \l {raw-command} {\\unicode}
79 \li \l {warning-command} {\\warning}
80 \li \l {backslash-sequence} {\\\\}
81 \li \l {endash-sequence} {\--}
82 \li \l {emdash-sequence} {-\--}
83 \endlist
84*/
85
86
87/*!
88 \page 04-qdoc-commands-textmarkup.html
89 \previouspage Markup Commands
90 \nextpage Document Structure
91
92 \title Text Markup
93
94 The text formatting commands indicate how text is to be rendered.
95
96 \target a-command
97 \section1 \\a (parameter marker)
98
99 The \\a command tells QDoc the next word is a formal parameter name.
100
101 A warning is emitted when a formal parameter is not documented or
102 is misspelled, so when you document a function you should mention
103 each formal parameter by name in the function description,
104 preceded by the \\a command. The parameter name is then rendered
105 in italics.
106
107 The formal parameter name may be enclosed between curly brackets,
108 but that isn't required.
109
110 \target c-command
111 \section1 \\c (code font)
112
113 The \\c command is used for rendering variable names, user-defined
114 class names, and C++ keywords (for example, \c int and \c for) in the code
115 font.
116
117 The command renders its argument using a monospace font. If the text to be
118 rendered in the code font contains spaces, enclose the entire text in curly
119 brackets:
120
121 \code
122 \c {QLineEdit::QLineEdit(const QString &contents, QWidget *parent) : QWidget(parent)}
123 \endcode
124
125 The \\c command accepts the special character \c \ within its
126 argument, which renders it as a normal character. So if you want
127 to use nested commands, you must use the \l {tt-command} {teletype
128 (\\tt)} command instead.
129
130 See also \l {tt-command} {\\tt} and \l {code-command} {\\code}.
131
132 \target details-command
133 \section1 \\details (collapsible)
134
135 The \\details and \\enddetails commands generates a collapsible <details>
136 element with a <summary> to control the hidden/visible state.
137
138 When generating HTML output, use the \\details and \\enddetails commands to
139 generate a collapsible \c{<details>} HTML element. The command takes an
140 optional summary string enclosed in curly braces. This optional argument
141 specifies a visible heading for the details.
142
143 For example, with the following input:
144 \badcode *
145 /\1!
146 \details {QDoc details}
147 \note You're looking at detailed information.
148 \enddetails
149 \1/
150 \endcode
151
152 If QDoc is generating HTML, it will translate these commands to:
153
154 \badcode
155 <summary>QDoc details</summary><div class="admonition note"><p><b>Note: </b>You're looking at detailed information.</p></div>
156 \endcode
157
158 QDoc renders this as:
159
160 \details {QDoc details}
161 \note You're looking at detailed information.
162 \enddetails
163
164 For any other output format, QDoc generates the contents as a normal paragraph,
165 ignoring the summary string. This command was introduced to QDoc in Qt6.6.
166
167 \target div-command
168 \section1 \\div
169
170 The \\div and \\enddiv commands delimit a large or small block of
171 text (which may include other QDoc commands) to which special
172 formatting attributes should be applied.
173
174 An argument must be provided in curly braces, as in the QDoc
175 comment shown below. The argument is not interpreted but is used
176 as attribute(s) of the tag that is output by QDoc.
177
178 For example, we might want to render an inline image so that it
179 floats to the right of the current block of text:
180
181 \badcode *
182 /\1!
183 \div {class="float-right"}
184 \inlineimage qml-column.png
185 \enddiv
186 \1/
187 \endcode
188
189 If QDoc is generating HTML, it will translate these commands to:
190
191 \code
192 <div class="float-right"><p><img src="images/qml-column.png" /></p></div>
193 \endcode
194
195 For HTML, the attribute value \e {float-right} then will refer to
196 a clause in the style.css file, which in this case could be:
197
198 \code
199 div.float-right
200 {
201 float: right; margin-left: 2em
202 }
203 \endcode
204
205 \note Note that the \b {\\div} command can be nested.
206
207 Below you can find an example taken from the index.qdoc file used to
208 generate index.html for Qt 4.7:
209
210 \code
211 \div {class="indexbox guide"}
212 \div {class="heading"}
213 Qt Developer Guide
214 \enddiv
215 \div {class="indexboxcont indexboxbar"}
216 \div {class="section indexIcon"} \emptyspan
217 \enddiv
218 \div {class="section"}
219 Qt is a cross-platform application and UI
220 framework. Using Qt, you can write web-enabled
221 applications once and deploy them across desktop,
222 mobile and embedded operating systems without
223 rewriting the source code.
224 \enddiv
225 \div {class="section sectionlist"}
226 \list
227 \li \l{Getting Started}
228 \li \l{Installation} {Installation}
229 \li \l{how-to-learn-qt.html} {How to learn Qt}
230 \li \l{tutorials.html} {Tutorials}
231 \li \l{Qt Examples} {Examples}
232 \li \l{qt4-7-intro.html} {What's new in Qt 4.7}
233 \endlist
234 \enddiv
235 \enddiv
236 \enddiv
237 \endcode
238
239 When all the class attribute values are defined as they are in the
240 style.css file that is used for rendering the Qt documentation,
241 the above example is rendered as:
242
243 \div {class="indexbox guide"}
244 \div {class="heading"}
245 Qt Developer Guide
246 \enddiv
247 \div {class="indexboxcont indexboxbar"}
248 \div {class="section indexIcon"} \emptyspan
249 \enddiv
250 \div {class="section"}
251 Qt is a cross-platform application and UI
252 framework. Using Qt, you can write web-enabled
253 applications once and deploy them across desktop,
254 mobile and embedded operating systems without
255 rewriting the source code.
256 \enddiv
257 \div {class="section sectionlist"}
258 \list
259 \li Getting Started
260 \li Installation
261 \li How to learn Qt
262 \li Tutorials
263 \li Examples
264 \li What's new in Qt 4.7
265 \endlist
266 \enddiv
267 \enddiv
268 \enddiv
269
270 See also \l {span-command} {\\span}.
271
272 \target span-command
273 \section1 \\span
274
275 The \\span command applies special formatting to a small block of text.
276
277 Two arguments must be provided, each argument in curly braces, as
278 shown in the QDoc comment below. The first argument is not
279 interpreted, but specifies the formatting attribute(s) of the tag
280 output by QDoc. The second argument is the text to be rendered with
281 the special formatting attributes.
282
283 For example, we might want to render the first word of each
284 element in a numeric list in blue.
285
286 \badcode *
287 /\1!
288 Global variables with complex types:
289 \list 1
290 \li \span {class="variableName"} {mutableComplex1} in globals.cpp at line 14
291 \li \span {class="variableName"} {mutableComplex2} in globals.cpp at line 15
292 \li \span {class="variableName"} {constComplex1} in globals.cpp at line 16
293 \li \span {class="variableName"} {constComplex2} in globals.cpp at line 17
294 \endlist
295 \1/
296 \endcode
297
298 Class \e {variableName} refers to a clause in your style.css.
299
300 \code
301 .variableName
302 {
303 font-family: courier;
304 color: blue
305 }
306 \endcode
307
308 Using the \e {variableName} clause shown above, the example is rendered as:
309
310 Global variables with complex types:
311 \list 1
312 \li \span {class="variableName"} {mutableComplex1} in globals.cpp at line 14
313 \li \span {class="variableName"} {mutableComplex2} in globals.cpp at line 15
314 \li \span {class="variableName"} {constComplex1} in globals.cpp at line 16
315 \li \span {class="variableName"} {constComplex2} in globals.cpp at line 17
316 \endlist
317
318 \note The \b span command does not cause a new paragraph to be
319 started.
320
321 See also \l {div-command} {\\div}.
322
323 \target tm-command
324 \section1 \\tm (trademark)
325
326 The \\tm command indicates that its argument is a trademark. QDoc appends
327 a trademark symbol `™` to the first occurrence of the argument when
328 generating a page.
329
330 In the project's configuration, the \c navigation.trademarkspage variable
331 is used for defining a title of a page that contains trademark-related
332 documentation.
333
334 \badcode
335 navigation.trademarkspage = Trademarks
336 \endcode
337
338 If set, each occurrence of the trademark symbol also links to the
339 trademarks page.
340
341 \note In section titles, the \\tm command is ignored and its argument
342 rendered as-is.
343
344 See also \l {sectionOne-command}{\\section1} and \qdocvar {navigation}.
345
346 \target tt-command
347 \section1 \\tt (teletype font)
348
349 The \\tt command renders its argument in a monospace font. This
350 command behaves just like the \l {c-command} {\\c} command, except
351 that \\tt allows you to nest QDoc commands within the argument
352 (e.g. \l {e-command} {\\e}, \l {b-command} {\\b} and \l
353 {underline-command} {\\underline}).
354
355 \badcode *
356 /\1!
357 After having populated the main container with
358 child widgets, \c setupUi() scans the main container's list of
359 slots for names with the form
360 \tt{on_\e{objectName}_\e{signalName}().}
361 \1/
362 \endcode
363
364 If the text to be rendered in the code font contains spaces, enclose the
365 entire text in curly brackets.
366
367 \code
368 \tt {QLineEdit::QLineEdit(const QString &contents, QWidget *parent) :QWidget(parent)}
369 \endcode
370
371 See also \l {c-command} {\\c}.
372
373 \target b-command
374 \section1 \\b
375
376 The \\b command renders its argument in bold font. This command used
377 to be called \\bold.
378
379 \badcode *
380 /\1!
381 This is regular text; \b {this text is
382 rendered using the \\b command}.
383 \1/
384 \endcode
385
386 \target br-command
387 \section1 \\br
388
389 The \\br command forces a line break.
390
391 \target e-command
392 \section1 \\e (emphasis, italics)
393
394 The \\e command renders its argument in a special font, normally italics. This
395 command used to be called \\i, which is now deprecated.
396
397 If the argument contains spaces or other punctuation, enclose the
398 argument in curly brackets.
399
400 \badcode *
401 /\1!
402 Here, we render \e {a few words} in italics.
403 \1/
404 \endcode
405
406 If you want to use other QDoc commands within an argument that
407 contains spaces, you always need to enclose the argument in
408 braces. But QDoc is smart enough to count parentheses, so you
409 don't need braces in cases like this:
410
411 \badcode *
412 /\1!
413 An argument can sometimes contain whitespaces,
414 for example: \e QPushButton(tr("A Brand New Button"))
415 \1/
416 \endcode
417
418 Finally, trailing punctuation is not included in an argument,
419 nor is "'s".
420
421 \target sub-command
422 \section1 \\sub
423
424 The \\sub command renders its argument lower than the baseline of
425 the regular text, using a smaller font.
426
427 \badcode *
428 /\1!
429 Definition (Range): Consider the sequence
430 {x\sub n}\sub {n > 1} . The set
431
432 {x\sub 2, x\sub 3, x\sub 4, ...} = {x\sub n ; n = 2, 3, 4, ...}
433
434 is called the range of the sequence.
435 \1/
436 \endcode
437
438 If the argument contains spaces or other punctuation, enclose the
439 argument in curly brackets.
440
441 \target sup-command
442 \section1 \\sup
443
444 The \\sup command renders its argument higher than
445 the baseline of the regular text, using a smaller font.
446
447 \badcode *
448 /\1!
449 The series
450
451 1 + a + a\sup 2 + a\sup 3 + a\sup 4 + ...
452
453 is called the \i {geometric series}.
454 \1/
455 \endcode
456
457 If the argument contains spaces or other punctuation, enclose the
458 argument in curly brackets.
459
460 \target uicontrol-command
461 \section1 \\uicontrol
462
463 The \\uicontrol command is used to mark content as being used for UI
464 control elements. When using HTML, the output is rendered in bold.
465
466 See also \l {b-command}{\\b}.
467
468 \target underline-command
469 \section1 \\underline
470
471 The \\underline command renders its argument underlined.
472
473 \badcode *
474 /\1!
475 The \underline {F}ile menu gives the users the possibility
476 to edit an existing file, or save a new or modified
477 file, and exit the application.
478 \1/
479 \endcode
480
481 If the argument contains spaces or other punctuation, enclose the
482 argument in curly brackets.
483
484 \target backslash-sequence
485 \section1 \\\\ (double backslash)
486
487 The sequence \\\\ expands to a single backslash.
488
489 QDoc commands always start with a single backslash. To display a
490 single backslash in the text, you must type two backslashes. If
491 you want to display two backslashes, you must type four.
492
493 \badcode *
494 /\1!
495 The \\\\ command is useful if you want a
496 backslash to appear verbatim, for example,
497 writing C:\\windows\\home\\.
498 \1/
499 \endcode
500
501 However, if you want your text to appear in a monospace font as
502 well, you can use the \l {c-command} {\\c} command instead, which
503 accepts and renders the backslash as any other character. For
504 example:
505
506 \badcode *
507 /\1!
508 The \\c command is useful if you want a
509 backslash to appear verbatim, and the word
510 that contains it written in a monospace font,
511 like this: \c {C:\windows\home\}.
512 \1/
513 \endcode
514
515 \target endash-sequence
516 \section1 \-- (en dash)
517 QDoc renders double hyphens as an en dash. QDoc markup commands
518 designed to make their input appear verbatim---such as the \\c
519 command---won't replace the double hyphens with an en dash character.
520 For example:
521
522 \badcode *
523 /\1!
524 The \\c command -- useful if you want text in a monospace font --
525 is well documented.
526 \1/
527 \endcode
528
529 However, other commands may require that the hyphens are escaped to ensure
530 QDoc renders the output as expected. For example;
531
532 \badcode *
533 /\1!
534 This \l {endash-sequence}{link to the -- (endash) sequence}
535 isn't escaped and QDoc therefore renders an endash in the link
536 text. However, the escaped
537 \l {endash-sequence}{link to the \-- (endash) sequence}
538 renders both hyphens as intended.
539 \1/
540 \endcode
541
542 See also \l {emdash-sequence}{\-\-- (em dash)}.
543
544 \target emdash-sequence
545 \section1 -\-- (em dash)
546
547 QDoc renders triple hyphens as an en dash. QDoc markup commands
548 designed to make their input appear verbatim---such as the \\c
549 command---won't replace the triple hyphens with an en dash character.
550 For example:
551
552 \badcode *
553 /\1!
554 The \\c command---useful when you want text to be rendered
555 verbatim---is well documented.
556 \1/
557 \endcode
558
559 However, other commands may require that the hyphens are escaped to ensure
560 QDoc renders the output as expected. For example;
561
562 \badcode *
563 /\1!
564 This \l {emdash-sequence}{link to the --- (emdash) sequence}
565 isn't escaped and QDoc therefore renders an emdash in the link
566 text. However, the escaped
567 \l {emdash-sequence}{link to the -\-- (emdash) sequence}
568 renders both hyphens as intended.
569 \1/
570 \endcode
571
572 \note The escaped control sequence in this example is for the en dash.
573 This avoids a hyphen followed by an en dash in the output.
574
575 See also \l {endash-sequence}{\-- (en dash)}.
576*/
577
578
579/*!
580 \page 05-qdoc-commands-documentstructure.html
581 \previouspage Text Markup
582 \nextpage Including Code Inline
583
584 \title Document Structure
585
586 The document structuring commands are for dividing your document
587 into sections. QDoc supports four levels of section: \c \section1,
588 \c \section2, \c \section3, and \c \section4. The section commands
589 correspond to the traditional section, subsection, etc used in
590 outlining.
591
592 \section1 Section commands
593
594 In general a document structuring command considers everything
595 that follows it until the first line break as its argument. The
596 argument is rendered as the unit's title. If the title needs to be
597 spanned over several lines, make sure that each line (except the
598 last one) is ended with a backslash.
599
600 In total, there are four levels for sections in QDoc: \c \section1,
601 \c \section2, \c \section3 and \c \section4. These correspond to the
602 traditional section, subsection, subsubsection and subsubsubsection.
603
604 There is a strict ordering of the section units:
605
606 \code
607 section1
608 |
609 section2
610 |
611 section3
612 |
613 section4
614 \endcode
615
616 When sections are used, the first section command should be \c section1.
617
618 \badcode *
619 /\1!
620 \section1 Basic Qt
621
622 This is the first section.
623
624
625 \section2 Getting Started
626
627 This is the first subsection.
628
629
630 \section3 Hello Qt
631
632 This is the first subsubsection.
633
634
635 \section3 Making Connections
636
637 This is the second subsubsection.
638
639
640 \section3 Using the Reference Documentation
641
642 This is the third subsubsection.
643
644
645 \section2 Creating Dialogs
646
647 This is the second subsection.
648
649
650 \section3 Subclassing QDialog
651
652 This is the first subsubsection.
653
654 ...
655
656
657 \section1 Intermediate Qt
658
659 This is the second section.
660
661
662 \section2 Layout Management
663
664 This is the second section's first subsection.
665
666
667 \section3 Basic Layouts
668
669 This is the first subsubsection.
670
671 ...
672 \1/
673 \endcode
674
675 Each section is a logical unit in the document. The section
676 heading appears in the automatically generated table of contents
677 that normally appears in the upper right-hand corner of the page.
678
679 \target sectionOne-command
680 \section1 \\section1
681
682 The \\section1 command starts a new section.
683
684 See \l{section-commands} {Section commands} for an explanation of the various
685 section units, command argument, and rendering.
686
687 \target sectionTwo-command
688 \section1 \\section2
689
690 The \\section2 command starts a new section.
691
692 See \l{section-commands} {Section commands} for an explanation of the various
693 section units, command argument, and rendering.
694
695 \target sectionThree-command
696 \section1 \\section3
697
698 The \\section3 command starts a new section.
699
700 See \l{section-commands} {Section commands} for an explanation of the various
701 section units, command argument, and rendering.
702
703 \target sectionFour-command
704 \section1 \\section4
705
706 The \\section4 command starts a new section.
707
708 See \l{section-commands} {Section commands} for an explanation of the various
709 section units, command argument, and rendering.
710
711*/
712
713
714/*!
715 \page 06-qdoc-commands-includecodeinline.html
716 \previouspage Document Structure
717 \nextpage Including External Code
718
719 \title Including Code Inline
720
721 The following commands are used to render source code without
722 formatting. The source code begins on a new line, rendered in the
723 code.
724
725 \note Although most of these commands are for rendering C++
726 code, the
727 \l{07-0-qdoc-commands-includingexternalcode.html#snippet-command}
728 {\\snippet} and
729 \l{07-0-qdoc-commands-includingexternalcode.html#codeline-command}
730 {\\codeline} commands are preferred over the others. These
731 commands allow equivalent code snippets for other Qt language
732 bindings to be substituted for the C++ snippets in the
733 documentation.
734
735 \target code-command
736 \section1 \\code
737
738 The \\code and \\endcode commands enclose a snippet of source code.
739
740 \note The \l {c-command} {\\c} command can be used for short code
741 fragments within a sentence. The \\code command is for longer code
742 snippets. It renders the code verbatim in a separate paragraph in
743 a html <pre> element, and parses the enclosed snippet, creating links
744 to any known types in the code.
745
746 For documenting command-line instructions, shell scripts, or any
747 content that is not in a Qt language recognized by QDoc, use
748 \l {badcode-command}{\\badcode} instead.
749
750 When processing the \\code command, QDoc removes all indentation
751 that is common for the verbatim code blocks within a \c{/}\c{*!}
752 ... \c{*}\c{/} comment before it adds the standard indentation.
753
754 \note This doesn't apply to externally quoted code using the \l
755 {quotefromfile-command} {\\quotefromfile} or \l
756 {quotefile-command} {\\quotefile} command.
757
758 \code \\endcode *
759 /*!
760 \code
761 #include <QApplication>
762 #include <QPushButton>
763
764 int main(int argc, char *argv[])
765 {
766 ...
767 }
768 \1
769 \2/
770 \endcode
771
772 Other QDoc commands are disabled within \\code... \\endcode, and
773 the special character '\\' is accepted and rendered like the rest
774 of the code, unless it is followed by a digit and parameters were
775 passed to \\code.
776
777 \section2 Highlighting and autolinking
778
779 The \\code commands attempts to parse its contents as code of a
780 specific language, as defined in the \l {language-variable}{language}
781 configuration variable. This provides highlighting and automatic
782 linking to types detected in the code.
783
784 As an exception since QDoc version 6.4, when the \\code command
785 is used within a QML-specific \l {Topic Commands}{topic}, QDoc
786 first attempts to recognize the code as QML; for other topics,
787 the language configuration variable takes precedence. To
788 explicitly mark the code snippet as QML, use the \l {qml-command}
789 {\\qml} command instead.
790
791 \section2 Code snippet parameters
792
793 Since QDoc version 5.12, \\code command accepts also optional
794 parameters. Parameters are useful for injecting simple
795 strings into the code snippet. To inject a string to a specific
796 location in the snippet, add a backslash followed by a digit (1..8).
797 The digits correspond with the order of the argument list, where
798 arguments are separated by spaces.
799
800 For example:
801
802 \badcode 1 2 * endcode
803 /\3!
804 \code * hello
805 /\\1 \\2 \\1/
806 \\4
807 \3/
808 \endcode
809
810 For the above snippet, QDoc renders the word \e hello enclosed in
811 a C-style comment.
812
813 \section2 Including code from external files
814
815 To include code snippets from an external file, use the
816 \l{snippet-command}{\\snippet} and \l{codeline-command}
817 {\\codeline} commands.
818
819 See also \l {c-command}{\\c}, \l {qml-command}{\\qml},
820 \l {badcode-command}{\\badcode}, \l {quotefromfile-command}
821 {\\quotefromfile}, and \l {language-variable}{language}.
822
823 \target badcode-command
824 \section1 \\badcode
825
826 Similar to \l {code-command}{\\code}, \\badcode and \\endcode commands
827 enclose content that is rendered verbatim in a separate paragraph, but no
828 parsing or automatic link creation is performed. Instead, the content is
829 treated as plain text.
830
831 Substitute \\code with this command when documenting command-line
832 instructions, shell scripts or any other content that is not in a Qt
833 language, but should still be styled similarly to a \\code paragraph.
834
835 Like \\code, \\badcode accepts also optional parameters.
836
837 \target qml-command
838 \section1 \\qml
839
840 The \\qml and \\endqml commands enclose a snippet of QML source
841 code. Use these for proper syntax highlighting of QML code snippets.
842 The enclosed snippet must be complete as if it was a valid .qml file.
843 If the snippet is incomplete, QDoc will issue a warning and ignore the
844 snippet.
845
846 \badcode *
847 /\1!
848 \qml
849 import QtQuick 2.0
850
851 Row {
852 Rectangle {
853 width: 100; height: 100
854 color: "blue"
855 transform: Translate { y: 20 }
856 }
857 Rectangle {
858 width: 100; height: 100
859 color: "red"
860 transform: Translate { y: -20 }
861 }
862 }
863 \endqml
864 \1/
865 \endcode
866
867 Like the \l{code-command}{\\code} command, \\qml accepts optional
868 parameters.
869*/
870
871
872/*!
873 \page 07-0-qdoc-commands-includingexternalcode.html
874 \previouspage Including Code Inline
875 \nextpage Creating Links
876
877 \title Including External Code
878
879 The following commands enable you to include code snippets from
880 external files. You can make QDoc include the complete contents of
881 a file, or you can quote specific parts of the file and skip
882 others. The typical use of the latter is to quote a file chunk by
883 chunk.
884
885 \note Although all these commands can be used for rendering C++
886 code, the
887 \l{07-0-qdoc-commands-includingexternalcode.html#snippet-command}
888 {\\snippet} and
889 \l{07-0-qdoc-commands-includingexternalcode.html#codeline-command}
890 {\\codeline} commands are preferred over the others. These
891 commands allow equivalent code snippets for other Qt language
892 bindings to be substituted for the C++ snippets in the
893 documentation.
894
895 \target quotefile-command
896 \section1 \\quotefile
897
898 The \\quotefile command expands to the complete contents of the
899 file given as argument.
900
901 The command considers the rest of the line as part of its
902 argument, make sure to follow the file name with a line break.
903
904 The file's contents is rendered in a separate paragraph, using a
905 monospace font and the standard indentation. The code is shown
906 verbatim.
907
908 \badcode *
909 /\1!
910 This is a simple "Hello world" example:
911
912 \quotefile examples/main.cpp
913
914 It contains only the bare minimum you need
915 to get a Qt application up and running.
916 \1/
917 \endcode
918
919 See also \l {quotefromfile-command} {\\quotefromfile} and
920 \l {code-command} {\\code}.
921
922
923 \target quotefromfile-command
924 \section1 \\quotefromfile
925
926 The \\quotefromfile command opens the file given as argument for
927 quoting.
928
929 The command considers the rest of the line as part of its
930 argument, make sure to follow the file name with a line break.
931
932 The command is intended for use when quoting parts from file with
933 the walkthrough commands: \l {printline-command} {\\printline}, \l
934 {printto-command} {\\printto}, \l {printuntil-command}
935 {\\printuntil}, \l {skipline-command} {\\skipline}, \l
936 {skipto-command} {\\skipto}, \l {skipuntil-command}
937 {\\skipuntil}. This enables you to quote specific portions of a
938 file.
939
940 \badcode *
941 /\1!
942 The whole application is contained within
943 the \c main() function:
944
945 \quotefromfile examples/main.cpp
946
947 \skipto main
948 \printuntil app(argc, argv)
949
950 First we create a QApplication object using
951 the \c argc and \c argv parameters.
952
953 \skipto QPushButton
954 \printuntil resize
955
956 Then we create a QPushButton, and give it a reasonable
957 size using the QWidget::resize() function.
958
959 ...
960 \1/
961 \endcode
962
963 QDoc remembers which file it is quoting from, and the current
964 position in that file (see \l {file} {\\printline} for more
965 information). There is no need to "close" the file.
966
967 See also \l {quotefile-command} {\\quotefile}, \l {code-command}
968 {\\code} and \l {dots} {\\dots}.
969
970 \target printline-command
971 \section1 \\printline
972
973 The \\printline command expands to the line from the current
974 position.
975
976 To ensure that the documentation remains synchronized with the
977 source file, a substring of the line must be specified as an
978 argument to the command. Note that the command considers the rest
979 of the line as part of its argument, make sure to follow the
980 substring with a line break.
981
982 The line from the source file is rendered as a separate paragraph,
983 using a monospace font and the standard indentation. The code is
984 shown verbatim.
985
986 \badcode *
987 /\1!
988 There has to be exactly one QApplication object
989 in every GUI application that uses Qt.
990
991 \quotefromfile examples/main.cpp
992
993 \printline QApplication
994
995 This line includes the QApplication class
996 definition. QApplication manages various
997 application-wide resources, such as the
998 default font and cursor.
999
1000 \printline QPushButton
1001
1002 This line includes the QPushButton class
1003 definition. The QPushButton widget provides a command
1004 button.
1005
1006 \printline main
1007
1008 The main function...
1009 \1/
1010 \endcode
1011
1012 \target file
1013
1014 QDoc reads the file sequentially. To move the current position
1015 forward you can use either of the \l {skipline-command}
1016 {\\skip...} commands. To move the current position backward, you
1017 can use the \l {quotefromfile-command} {\\quotefromfile} command
1018 again.
1019
1020 \target substring
1021
1022 If the substring argument is surrounded by slashes it is
1023 interpreted as a \l {QRegularExpression}{regular expression}.
1024
1025 \badcode *
1026 /\1!
1027 \quotefromfile examples/mainwindow.cpp
1028
1029 \skipto closeEvent
1030 \printuntil /^\}/
1031
1032 Close events are sent to widgets that the users want to
1033 close, usually by clicking \c File|Exit or by clicking
1034 the \c X title bar button. By reimplementing the event
1035 handler, we can intercept attempts to close the
1036 application.
1037 \1/
1038 \endcode
1039
1040 (\l {widgets/scribble} {The complete example file...})
1041
1042 The regular expression \c /^\}/ makes QDoc print until the first
1043 '}' character occurring at the beginning of the line without
1044 indentation. /.../ encloses the regular expression, and '^' means
1045 the beginning of the line. The '}' character must be escaped since
1046 it is a special character in regular expressions.
1047
1048 QDoc will emit a warning if the specified substring or regular
1049 expression cannot be located, i.e. if the source code has changed.
1050
1051 See also \l {printto-command} {\\printto} and \l
1052 {printuntil-command} {\\printuntil}.
1053
1054 \target printto-command
1055 \section1 \\printto
1056
1057 The \\printto command expands to all the lines from the current
1058 position up to and \e excluding the next line containing a given
1059 substring.
1060
1061 The command considers the rest of the line as part of its
1062 argument, make sure to follow the substring with a line break. The
1063 command also follows the same conventions for \l {file}
1064 {positioning} and \l {substring} {argument} as the \l
1065 {printline-command} {\\printline} command.
1066
1067 The lines from the source file are rendered in a separate
1068 paragraph, using a monospace font and the standard
1069 indentation. The code is shown verbatim.
1070
1071 \badcode *
1072 /\1!
1073 The whole application is contained within the
1074 \c main() function:
1075
1076 \quotefromfile examples/main.cpp
1077 \printto hello
1078
1079 First we create a QApplication object using the \c argc and
1080 \c argv parameters...
1081 \1/
1082 \endcode
1083
1084 See also \l {printline-command} {\\printline} and \l
1085 {printuntil-command} {\\printuntil}.
1086
1087 \target printuntil-command
1088 \section1 \\printuntil
1089
1090 The \\printuntil command expands to all the lines from the current
1091 position up to and \e including the next line containing a given
1092 substring.
1093
1094 The command considers the rest of the line as part of its
1095 argument, make sure to follow the substring with a line break. The
1096 command also follows the same conventions for \l {file}
1097 {positioning} and \l {substring} {argument} as the \l
1098 {printline-command} {\\printline} command.
1099
1100 If \\printuntil is used without an argument, it expands to all the
1101 lines from the current position to the end of the quoted file.
1102
1103 The lines from the source file are rendered in a separate
1104 paragraph, using a monospace font and the standard
1105 indentation. The code is shown verbatim.
1106
1107 \badcode *
1108 /\1!
1109 The whole application is contained within the
1110 \c main() function:
1111
1112 \quotefromfile examples/main.cpp
1113 \skipto main
1114 \printuntil hello
1115
1116 First we create a QApplication object using the
1117 \c argc and \c argv parameters, then we create
1118 a QPushButton.
1119 \1/
1120 \endcode
1121
1122 See also \l {printline-command} {\\printline} and \l
1123 {printto-command} {\\printto}.
1124
1125 \target skipline-command
1126 \section1 \\skipline
1127
1128 The \\skipline command ignores the next non-blank line in the
1129 current source file.
1130
1131 Doc reads the file sequentially, and the \\skipline command is
1132 used to move the current position (omitting a line of the source
1133 file). See the remark about \l {file} {file positioning} above.
1134
1135 The command considers the rest of the line as part of its
1136 argument, make sure to follow the substring with a line break. The
1137 command also follows the same conventions for \l {substring}
1138 {argument} as the \l {printline-command} {\\printline} command,
1139 and it is used in conjunction with the \l {quotefromfile-command}
1140 {\\quotefromfile} command.
1141
1142 \badcode *
1143 /\1!
1144 QPushButton is a GUI push button that the user
1145 can press and release.
1146
1147 \quotefromfile examples/main.cpp
1148 \skipline QApplication
1149 \printline QPushButton
1150
1151 This line includes the QPushButton class
1152 definition. For each class that is part of the
1153 public Qt API, there exists a header file of
1154 the same name that contains its definition.
1155 \1/
1156 \endcode
1157
1158
1159 See also \l {skipto-command} {\\skipto}, \l {skipuntil-command}
1160 {\\skipuntil} and \l {dots} {\\dots}.
1161
1162 \target skipto-command
1163 \section1 \\skipto
1164
1165 The \\skipto command ignores all the lines from the current
1166 position up to and \e excluding the next line containing a given
1167 substring.
1168
1169 QDoc reads the file sequentially, and the \\skipto command is used
1170 to move the current position (omitting one or several lines of the
1171 source file). See the remark about \l {file} {file positioning}
1172 above.
1173
1174 The command considers the rest of the line as part of its
1175 argument, make sure to follow the substring with a line break.
1176
1177 The command also follows the same conventions for \l {substring}
1178 {argument} as the \l {printline-command} {\\printline} command,
1179 and it is used in conjunction with the \l {quotefromfile-command}
1180 {\\quotefromfile} command.
1181
1182 \badcode *
1183 /\1!
1184 The whole application is contained within
1185 the \c main() function:
1186
1187 \quotefromfile examples/main.cpp
1188 \skipto main
1189 \printuntil }
1190
1191 First we create a QApplication object. There
1192 has to be exactly one such object in
1193 every GUI application that uses Qt. Then
1194 we create a QPushButton, resize it to a reasonable
1195 size ...
1196 \1/
1197 \endcode
1198
1199 See also \l {skipline-command} {\\skipline}, \l
1200 {skipuntil-command} {\\skipuntil} and \l {dots} {\\dots}.
1201
1202 \target skipuntil-command
1203 \section1 \\skipuntil
1204
1205 The \\skipuntil command ignores all the lines from the current
1206 position up to and \e including the next line containing a given
1207 substring.
1208
1209 QDoc reads the file sequentially, and the \\skipuntil command is
1210 used to move the current position (omitting one or several lines
1211 of the source file). See the remark about \l {file} {file
1212 positioning} above.
1213
1214 The command considers the rest of the line as part of its
1215 argument, make sure to follow the substring with a line break.
1216
1217 The command also follows the same conventions for \l {substring}
1218 {argument} as the \l {printline-command} {\\printline} command,
1219 and it is used in conjunction with the \l {quotefromfile-command}
1220 {\\quotefromfile} command.
1221
1222 \badcode *
1223 /\1!
1224 The first thing we did in the \c main() function
1225 was to create a QApplication object \c app.
1226
1227 \quotefromfile examples/main.cpp
1228 \skipuntil show
1229 \dots
1230 \printuntil }
1231
1232 In the end we must remember to make \c main() pass the
1233 control to Qt. QCoreApplication::exec() will return when
1234 the application exits...
1235 \1/
1236 \endcode
1237
1238 See also \l {skipline-command} {\\skipline}, \l {skipto-command}
1239 {\\skipto} and \l {dots} {\\dots}.
1240
1241 \target dots-command
1242 \section1 \\dots
1243
1244 The \\dots command indicates that parts of the source file have
1245 been omitted when quoting a file.
1246
1247 The command is used in conjunction with the \l
1248 {quotefromfile-command} {\\quotefromfile} command, and should be
1249 stated on its own line. The dots are rendered on a new line, using
1250 a monospace font.
1251
1252 \badcode *
1253 /\1!
1254 \quotefromfile examples/main.cpp
1255 \skipto main
1256 \printuntil {
1257 \dots
1258 \skipuntil exec
1259 \printline }
1260 \1/
1261 \endcode
1262
1263 The default indentation is 4 spaces, but this can be adjusted
1264 using the command's optional argument.
1265
1266 \badcode *
1267 /\1!
1268 \dots 0
1269 \dots
1270 \dots 8
1271 \dots 12
1272 \dots 16
1273 \1/
1274 \endcode
1275
1276 See also \l {skipline-command} {\\skipline}, \l {skipto-command}
1277 {\\skipto} and \l {skipuntil-command} {\\skipuntil}.
1278
1279 \target snippet-command
1280 \section1 \\snippet
1281
1282 The \\snippet command causes a code snippet to be included
1283 verbatim as preformatted text, which may be syntax highlighted.
1284
1285 Each code snippet is referenced by the file that holds it and by
1286 a unique identifier for that file. Snippet files are typically
1287 stored in a \c{snippets} directory inside the documentation
1288 directory (for example, \c{$QTDIR/doc/src/snippets}).
1289
1290 For example, the following documentation references a snippet in a
1291 file residing in a subdirectory of the documentation directory:
1292
1293 \code
1294 \snippet snippets/textdocument-resources/main.cpp Adding a resource
1295 \endcode
1296
1297 The text following the file name is the unique identifier for the
1298 snippet. This is used to delimit the quoted code in the relevant
1299 snippet file, as shown in the following example that corresponds to
1300 the above \c{\snippet} command:
1301
1302 \code
1303 ...
1304 QImage image(64, 64, QImage::Format_RGB32);
1305 image.fill(qRgb(255, 160, 128));
1306
1307//! [Adding a resource]
1308 document->addResource(QTextDocument::ImageResource,
1309 QUrl("mydata://image.png"), QVariant(image));
1310//! [Adding a resource]
1311 ...
1312 \endcode
1313
1314 By default, QDoc looks for \c{//!} as a code snippet marker.
1315 For \c{.pro}, \c{.py}, \c{.cmake}, and \c{CMakeLists.txt}
1316 files, \c {#!} is detected. Finally, \c{<!--} is accepted in
1317 \c{.html}, \c{.qrc}, \c{.ui}, \c{.xml}, and \c{.xq} files.
1318
1319 QDoc normalizes snippet indentation by comparing the snippet-marker's
1320 space-based indentation against the snippet's minimum content indentation
1321 (ignoring Qt-macros, blank lines, and full-line comments). It then
1322 automatically un-indents the snippet body to whichever is smaller,
1323 ensuring the generated code always preserves its natural structure
1324 regardless of where the markers sit. Under-indented markers are left
1325 untouched.
1326
1327 \note QDoc only handles space characters for indentation normalization,
1328 not tabs or other whitespace. For best results, use consistent space-based
1329 indentation in source files containing snippets.
1330
1331 \target codeline-command
1332 \section1 \\codeline
1333
1334 The \\codeline command inserts a blank line of preformatted
1335 text. It is used to insert gaps between snippets without closing
1336 the current preformatted text area and opening a new one.
1337
1338*/
1339
1340
1341/*!
1342 \page 08-qdoc-commands-creatinglinks.html
1343 \previouspage Including External Code
1344 \nextpage Including Images
1345
1346 \title Creating Links
1347
1348 These commands are for creating hyperlinks to classes, functions,
1349 examples, and other targets.
1350
1351 \target l-command
1352 \section1 \\l (link)
1353
1354 The \\l link command is used to create a hyperlink to many
1355 different kinds of targets. The command's general syntax is:
1356
1357 \code
1358 \l [ link criteria ] { link target } { link text }
1359 \endcode
1360
1361 ...where the \c {link criteria} in square brackets are optional
1362 but may be required when the \c {link target} is ambiguous. See
1363 \l {Fixing Ambiguous Links} below.
1364
1365 You can use the \\l command to link to:
1366
1367 \list
1368
1369 \li an external page:
1370
1371 \badcode
1372 An URL with a custom link text:
1373 \l {http://doc.qt.io/qt-6/} {Qt 6 Documentation}.
1374
1375 An URL without a custom link text: \l {http://doc.qt.io/qt-6/}.
1376 \endcode
1377
1378 Renders as:
1379
1380 An URL with a custom link text:
1381 \l {http://doc.qt.io/qt-6/} {Qt 6 Documentation}.
1382
1383 An URL without a custom link text: \l {http://doc.qt.io/qt-6/}.
1384
1385 See also \l {externalpage-command}{\\externalpage}.
1386
1387 \li a documentation page. The link target can be:
1388
1389 \list
1390 \li the page title specified with the \l {title-command} {\\title}
1391 command:
1392
1393 \badcode
1394 Here is a link with a custom link text:
1395 \l {Getting Started with QDoc}{QDoc - Getting Started}.
1396
1397 Here is a link with a link text that is the same as the link
1398 target: \l {Getting Started with QDoc}.
1399 \endcode
1400
1401 Renders as:
1402
1403 Here is a link with a custom link text:
1404 \l {Getting Started with QDoc}{QDoc - Getting Started}.
1405
1406 Here is a link with a link text that is the same as link target:
1407 \l {Getting Started with QDoc}.
1408
1409 \li the page file name specified with the \l {page-command} {\\page}
1410 command:
1411
1412 \badcode
1413 \page 08-qdoc-commands-creatinglinks.html
1414 \title Creating Links
1415
1416 These commands are for creating hyperlinks to classes, functions,
1417 examples, and other targets.
1418
1419 ...
1420
1421 The \l {08-qdoc-commands-creatinglinks.html} {Creating Links page}
1422 explains how to create links with QDoc.
1423 \endcode
1424
1425 Renders as:
1426
1427 The \l {08-qdoc-commands-creatinglinks.html} {Creating Links page}
1428 article explains how to create links with QDoc.
1429
1430 \li the page with a \l {keyword-command} {\\keyword} command.
1431 \endlist
1432
1433 \li a particular anchor section within a document. The link target can be:
1434
1435 \list
1436 \li a section title specified with one of the
1437 \l{section-commands} {Section commands}:
1438
1439 \badcode
1440 Here is a link to a QDoc Commands section of the Writing
1441 Documentation topic:
1442 \l {Writing Documentation#QDoc Commands}{QDoc Commands}.
1443
1444 If you have unique section titles across your documentation
1445 project, you can use the section title as a target without
1446 the need to add the topic title:
1447 \l {QDoc Commands}.
1448 \endcode
1449
1450 Renders as:
1451
1452 Here is a link to a QDoc Commands section of the Writing
1453 Documentation topic:
1454 \l {Writing Documentation#QDoc Commands}{QDoc Commands}.
1455
1456 If you have unique section titles across your documentation
1457 project, you can use the section title as a target without the
1458 need to add the topic title:
1459 \l {QDoc Commands}.
1460
1461 \li an anchor defined with a \l {target-command}{\\target} command:
1462 \badcode
1463 \target assertions
1464
1465 Assertions make some statement about the text at the
1466 point where they occur in the regexp, but they do not
1467 match any characters.
1468
1469 ...
1470
1471 Regexps are built up from expressions, quantifiers, and
1472 \l {assertions} {assertions}.
1473
1474 \endcode
1475
1476 \endlist
1477
1478 \li an API item. Target links can be:
1479
1480 \list
1481 \li \c {\l QWidget} - The name of a class documented with the
1482 \l {class-command} {\\class} or
1483 \l {qmltype-command}{\\qmltype} command.
1484
1485 \li \c {\l QWidget::sizeHint()} - The signature of a function
1486 without parameters. If a matching function without
1487 parameters can't be found, the link is satisfied with the
1488 first matching function found.
1489
1490 \li \c {\l QWidget::removeAction(QAction* action)} - The
1491 signature of a function with parameters. If an exact match is
1492 not found, the link is not satisfied and QDoc reports a
1493 \e {Can't link to...} error.
1494
1495 \li \c {\l <QtGlobal>} - The subject of a \l {headerfile-command}
1496 {\\headerfile} command.
1497
1498 \endlist
1499 \li an example. The target link is the example title or a relative path
1500 used in an \l {example-command} {\\example} command:
1501
1502 \badcode *
1503 /\1!
1504 \example widgets/imageviewer
1505 \title ImageViewer Example
1506 \brief Shows how to combine QLabel and QScrollArea
1507 to display an image.
1508
1509 ...
1510 \1/
1511
1512 ...
1513
1514 See the example: \l widgets/imageviewer
1515 \endcode
1516 \endlist
1517
1518 If the link target is equivalent to the link text, you can omit the second
1519 argument.
1520
1521 For example, if you have documentation like:
1522
1523 \badcode *
1524 /\1!
1525 \target assertions
1526
1527 Assertions make some statement about the text at the
1528 point where they occur in the regexp, but they do not
1529 match any characters.
1530
1531 ...
1532
1533 Regexps are built up from expressions, quantifiers, and
1534 \l {assertions} {assertions}.
1535 \1/
1536 \endcode
1537
1538 You can simplify this as follows:
1539
1540 \badcode *
1541 /\1!
1542 \target assertions
1543
1544 Assertions make some statement about the text at the
1545 point where they occur in the regexp, but they do not
1546 match any characters.
1547
1548 ...
1549
1550 Regexps are built up from expressions, quantifiers, and
1551 \l assertions.
1552 \1/
1553 \endcode
1554
1555 For the one-parameter version, the braces can often be omitted.
1556
1557 QDoc also tries to make a link out of any word that doesn't
1558 resemble a normal English word, for example, Qt class names or
1559 functions, like QWidget or QWidget::sizeHint(). In these cases,
1560 the \\l command can actually be omitted, but by using the command,
1561 you ensure that QDoc will emit a warning if it cannot find the
1562 link target. In addition, if you only want the function name to
1563 appear in the link, you can use the following syntax:
1564
1565 \list
1566 \li \c {\l {QWidget::} {sizeHint()}}
1567 \endlist
1568
1569 \section2 Fixing Ambiguous Links
1570
1571 Because of the modularization of Qt beginning with Qt 5.0, The
1572 possibility that QDoc will have to deal with ambiguous links has
1573 increased. An ambiguous link is one that has a matching target in
1574 more than one Qt module, for example, the same section title can appear in
1575 more than one Qt module, or the name of a C++ class in one module
1576 can also be the name of a QML type in another module. A real
1577 example in Qt5 is the name Qt itself. Qt is the name of both a C++
1578 namespace in QtCore and a QML type in QtQml.
1579
1580 Suppose we want to link to the \l {Qt} {Qt C++ namespace}. At the
1581 time QDoc generated this HTML page, that link was correct. Does
1582 it still go to the C++ namespace? Qdoc generated that link from
1583 this link command:
1584
1585 \list
1586 \li \c {\l {Qt} {Qt C++ namespace}}
1587 \endlist
1588
1589 Now suppose we want to link to the \l [QML] {Qt} {Qt QML type}.
1590 At the time QDoc generated this HTML page, that link was also
1591 correct, but we had to use this link command:
1592
1593 \list
1594 \li \c {\l [QML] {Qt} {Qt QML type}}
1595 \endlist
1596
1597 The \e {QML} in \e {square brackets} tells QDoc to accept a
1598 matching target only if the target is on a QML page. Qdoc actually
1599 finds the C++ namespace target first, but since that target is on
1600 a C++ page, QDoc ignores it and keeps looking until it finds the
1601 same target on a QML page.
1602
1603 Without the guidance in the \e{\\l command} in the optional \e
1604 {square bracket} argument, QDoc links to the first matching target
1605 it finds. QDoc can't warn that the link was ambiguous in such
1606 cases because it doesn't know that another matching target exists.
1607
1608 \section2 What arguments can appear in square brackets?
1609
1610 A link command with square bracket argument has the following syntax:
1611 \list
1612 \c {\l [QML|CPP|DOC|QtModuleName] {link target} {link text}}
1613 \endlist
1614
1615 The \e {square bracket} argument is only allowed in the \c {\l
1616 (link)} command. The example above shows how \c QML is used as the
1617 \e {square brackets} argument to force QDoc to match a QML target.
1618 Most often, this will be a QML type, but it can also be a QML
1619 member function of property.
1620
1621 In the example, QDoc didn't need a \e {square bracket} argument to
1622 find the Qt C++ namespace page, because that one was the first
1623 matching target QDoc found anyway. However, to force QDoc to find
1624 a C++ target when a matching QML target gets in the way, \c CPP
1625 can be used as the \e {square bracket} argument. For example:
1626
1627 \list
1628 \li \c {\l [CPP] {Qt} {Qt C++ namespace}}
1629 \endlist
1630
1631 ...will force QDoc to ignore the Qt QML type and continue
1632 searching until it matches the Qt C++ namespace.
1633
1634 If the link target is neither a C++ nor a QML entity, \c {DOC} can
1635 be used as the \e {square bracket} argument to prevent QDoc from
1636 matching either of those. At this writing, there were no cases of
1637 ambiguous links where using \c {DOC} was required.
1638
1639 Often, the documentor knows which Qt module the link target is
1640 in. When the module name is known, use the module name as the \e
1641 {square bracket} argument. In the example above, if we know that
1642 the QML type named Qt is located in the QtQml module, we can write
1643 the link command like this:
1644
1645 \list
1646 \li \c {\l [QtQml] {Qt} {Qt QML type}}
1647 \endlist
1648
1649 When a module name is used as the \e {square bracket} argument,
1650 QDoc will search for the link target in that module only. This
1651 makes searching for link targets more efficient.
1652
1653 Finally, the module name and entity type arguments can be
1654 combined, separated by a blank, so something like this is also
1655 allowed:
1656
1657 \list
1658 \li \c {\l [CPP QtQml] {Window} {C++ class Window}}
1659 \endlist
1660
1661 As of this writing, there were no cases where combining the two
1662 was required.
1663
1664 See also \l {sa-command} {\\sa}, \l {target-command} {\\target},
1665 and \l {keyword-command} {\\keyword}.
1666
1667
1668 \target sa-command
1669 \section1 \\sa (see also)
1670
1671 The \\sa command defines a list of links that will be rendered in
1672 a separate "See also" section at the bottom of the documentation
1673 unit.
1674
1675 The command takes a comma-separated list of links as its
1676 argument. If the line ends with a comma, you can continue
1677 the list on the next line. The general syntax is:
1678
1679 \code
1680 \sa {the first link}, {the second link},
1681 {the third link}, ...
1682 \endcode
1683
1684 QDoc will automatically try to generate "See also" links
1685 interconnecting a property's various functions. For example, a
1686 setVisible() function will automatically get a link to visible()
1687 and vice versa.
1688
1689 In general, QDoc will generate "See also" links that interconnect
1690 the functions that access the same property. It recognizes four
1691 different syntax versions:
1692
1693 \list
1694 \li \c property()
1695 \li \c setProperty()
1696 \li \c isProperty()
1697 \li \c hasProperty()
1698 \endlist
1699
1700 The \\sa command supports the same kind of links as the \l
1701 {l-command} {\\l} command.
1702
1703 \badcode *
1704 /\1!
1705 Appends the actions \a actions to this widget's
1706 list of actions.
1707
1708 \sa removeAction(), QMenu, addAction()
1709 \1/
1710 void QWidget::addActions(QList<QAction *> actions)
1711 {
1712 ...
1713 }
1714 \endcode
1715
1716 See also \l {l-command} {\\l}, \l {target-command} {\\target} and
1717 \l {keyword-command} {\\keyword}.
1718
1719
1720 \target target-command
1721 \section1 \\target
1722
1723 The \\target command names a place in the documentation that you
1724 can link to using the \l {l-command} {\\l (link)} and \l
1725 {sa-command} {\\sa (see also)} commands.
1726
1727 \e{The text up to the line break becomes the target name}. Be sure
1728 to follow the target name with a line break. Curly brackets are not
1729 required around the target name, but they may be required when the
1730 target name is used in a link command. See below.
1731
1732 \badcode *
1733 /\1!
1734 \target capturing parentheses
1735 \section1 Capturing Text
1736
1737 Parentheses allow us to group elements together so that
1738 we can quantify and capture them.
1739
1740 ...
1741 \1/
1742 \endcode
1743
1744 The target name \e{capturing parentheses} can be linked to
1745 in the following way:
1746
1747 \list
1748 \li \c {\l {capturing parentheses}}
1749 \endlist
1750
1751 \note The brackets in the link example are required because the
1752 target name contains spaces.
1753
1754 \section2 \\target in a \\table
1755 When you use the \\target command in a table, make sure that the
1756 \\target command follows a \l {li-command}{\\li}-command (table
1757 cell), as some generators only support targets to an individual cell,
1758 not to a whole row.
1759 Moreover, ensure that it's either on a separate line, or the last content
1760 that occurs in the line it's in. This is due to how the \\target
1761 command works; it consumes anything up to the next line break as
1762 its parameter. In other words, if you have a table and need a
1763 \\target within it, make sure that it follows the following
1764 structure:
1765
1766 \badcode
1767 \table
1768 \row
1769 \li \target my-target
1770 My text goes here.
1771 \li This is my next table cell.
1772 \endtable
1773 \endcode
1774
1775 See also \l {l-command} {\\l}, \l {sa-command} {\\sa} and \l
1776 {keyword-command} {\\keyword}.
1777
1778 \target keyword-command
1779 \section1 \\keyword
1780
1781 The \\keyword command names a place in the documentation that you
1782 can link to using the \l {l-command} {\\l (link)} and \l
1783 {sa-command} {\\sa (see also)} commands. It also adds the keyword
1784 and the location to generated indices.
1785
1786 The \\keyword command is like the \l {target-command} {\\target}
1787 command, except that when linking to a keyword, by default the link
1788 goes to the top of the QDoc comment (topic) the \\keyword appears in.
1789
1790 If you want to create a keyword for a \c section unit within a
1791 topic, add the \\keyword directly above the section title:
1792
1793 \badcode
1794 \keyword debug
1795 \section1 Debug command line option (--debug)
1796 ...
1797 \endcode
1798
1799 Unlike \\target, keywords are registered in indices of generated
1800 offline documentation files (.qch). This allows users to look up the
1801 location by keyword, for instance, in
1802 \l[QtAssistant]{Searching for Keywords}{Qt Assistant's Index Search},
1803 and makes the keyword accessible in \QC's context help.
1804
1805 Keywords must be unique over all the documents processed during
1806 the QDoc run. The command uses the rest of the line as its
1807 argument. Be sure to follow the keyword with a line break.
1808
1809
1810 \badcode *
1811 /\1!
1812 \class QRegularExpression
1813 \reentrant
1814 \brief The QRegularExpression class provides pattern
1815 matching using regular expressions.
1816 \ingroup tools
1817 \ingroup misc
1818 \ingroup shared
1819
1820 \keyword regular expression
1821
1822 Regular expressions, or "regexps", provide a way to
1823 find patterns within text.
1824
1825 ...
1826 \1/
1827 \endcode
1828
1829 The location marked with the keyword can be linked to with:
1830
1831 \badcode *
1832 /\1!
1833 When a string is surrounded by slashes, it is
1834 interpreted as a \l {regular expression}.
1835 \1/
1836 \endcode
1837
1838 If the keyword text contains spaces, the brackets are required.
1839
1840 See also \l {l-command} {\\l (link)}, \l {sa-command} {\\sa (see
1841 also)} and \l {target-command} {\\target}.
1842
1843*/
1844
1845
1846/*!
1847 \page 09-qdoc-commands-includingimages.html
1848 \previouspage Creating Links
1849 \nextpage Tables and Lists
1850
1851 \title Including Images
1852
1853 The graphic commands makes it possible to include images in the
1854 documentation. The images can be rendered as separate paragraphs,
1855 or within running text.
1856
1857 \target image-command
1858 \section1 \\image
1859
1860 The \\image command expands to the image specified by its first
1861 argument, and renders it centered as a separate paragraph.
1862
1863 The command takes two arguments. The first argument is the name of
1864 the image file. The second argument is a description of what
1865 the image contains, and is used for the HTML \c alt attribute.
1866 Its contents is read aloud by screen readers, and its use is therefore
1867 strongly recommended for accessibility purposes. It may also be used by
1868 browsers that don't support images, like the Lynx text browser. You
1869 can also set the \l {usealttextastitle-variable} {usealttextastitle}
1870 variable to make QDoc generate a \e title attribute for the image, which
1871 commonly is rendered by graphical text browsers as a tooltip when the user
1872 hovers the mouse over the image.
1873
1874 While QDoc is quite forgiving, you should wrap both the file name and the
1875 description in curly braces, like so:
1876 \badcode
1877 \image {Bandit.png} {A Golden Retriever holding a bag of coffee in its mouth}
1878 \endcode
1879 This syntax is the most explicit and should always give the expected result.
1880 If not, be sure to follow the file name or the description with a line break.
1881 Curly brackets are required if the description argument spans multiple lines.
1882 If the description is wrapped in double quotes, QDoc will remove them before
1883 generating output. Special characters may be replaced with the corresponding
1884 HTML entity code in QDoc's HTML output.
1885
1886 \badcode *
1887 /\1!
1888 Qt is a C++ toolkit for cross-platform GUI application development.
1889
1890 \image {happyguy.jpg} {Happy guy}
1891
1892 Qt provides single-source portability across Microsoft
1893 Windows, macOS, Linux, and all major commercial Unix
1894 variants. It is also available for embedded devices.
1895 \1/
1896 \endcode
1897
1898 See also \l {inlineimage-command} {\\inlineimage} and \l
1899 {caption-command} {\\caption}.
1900
1901 \target inlineimage-command
1902 \section1 \\inlineimage
1903
1904 The \\inlineimage command expands to the image specified by its
1905 argument. The image is rendered inline with the rest of the text.
1906
1907 The command takes two arguments. The first argument is the name of
1908 the image file. The second argument is optional and is a simple
1909 description of the image within braces {}, equivalent to the HTML
1910 alt="" in an image tag. The description is used for tooltips, and
1911 for when a browser doesn't support images, like the Lynx text browser.
1912
1913 The most common use of the \\inlineimage command is in lists and
1914 tables. Here is an example of including inline images in a list:
1915
1916 \badcode *
1917 /\1!
1918 \list 1
1919 \li \inlineimage happy.gif {Oh so happy, I am a caption!}
1920 \li \inlineimage happy.gif Oh so happy, but I'm not a caption.
1921 \endlist
1922 \1/
1923 \endcode
1924
1925 Here is an example of including inline images in a table:
1926
1927 \badcode *
1928 /\1!
1929 \table
1930 \header
1931 \li Qt
1932 \li Qt Creator
1933 \row
1934 \li \inlineimage happy.gif {Oh so happy!}
1935 \li \inlineimage happy.gif Oh so happy!
1936 \row
1937 \li \inlineimage happy.gif Oh so happy!
1938 \li \inlineimage happy.gif {Oh so happy!}
1939 \endtable
1940 \1/
1941 \endcode
1942
1943 The command can also be used to insert an image inline with the
1944 text.
1945
1946 \badcode *
1947 /\1!
1948 \inlineimage training.jpg {Qt Training} The Qt Programming course is
1949 offered as a five day Open Enrollment Course. The classes are open to
1950 the public. Although the course is open to anyone who wants to learn,
1951 attendees should have significant experience in C++ development to
1952 derive maximum benefit from the course.
1953 \1/
1954 \endcode
1955
1956 See also \l {image-command} {\\image} and \l {caption-command} {\\caption}.
1957
1958 \target caption-command
1959 \section1 \\caption
1960
1961 The \\caption command provides a caption for an image.
1962
1963 The command takes all the text up to the end of the paragraph to
1964 be the caption. Experiment until you get the effect you want.
1965
1966 \badcode *
1967 /\1!
1968 \table 100%
1969 \row
1970 \li \image windows-pushbutton.png
1971 \caption The QPushButton widget provides a command button.
1972 \li \image windows-toolbutton.png
1973 \caption The QToolButton class provides a quick-access button to commands
1974 or options, usually used inside a QToolBar.
1975 \endtable
1976 \1/
1977 \endcode
1978
1979 See also \l {image-command} {\\image} and \l {inlineimage-command}
1980 {\\inlineimage}
1981*/
1982
1983
1984/*!
1985 \page 10-qdoc-commands-tablesandlists.html
1986 \previouspage Including Images
1987 \nextpage Special Content
1988
1989 \title Tables and Lists
1990
1991 These commands enable creating lists and tables. A list is
1992 rendered left aligned as a separate paragraph. A table is rendered
1993 centered as a separate paragraph. The table width depends on the
1994 width of its contents.
1995
1996 \target table-command
1997 \section1 \\table
1998
1999 The \\table and \\endtable commands delimit the contents of a
2000 table.
2001
2002 The command accepts a single argument specifying the table's width
2003 as a percentage of the page width:
2004
2005 \badcode *
2006 /\1!
2007 \table 100 %
2008
2009 ...
2010
2011 \endtable
2012 \1/
2013 \endcode
2014
2015 The code above ensures that the table will fill all available
2016 space. If the table's width is smaller than 100 %, the table will
2017 be centered in the generated documentation.
2018
2019 A table can contain headers, rows and columns. A row starts with a
2020 \l {row-command} {\\row} command and consists of cells, each of which
2021 starts with an \l {li-command} {\\li} command. There is also a \l
2022 {header-command} {\\header} command which is a special kind of row
2023 that has a special format.
2024
2025 \badcode *
2026 /\1!
2027 \table
2028 \header
2029 \li Qt Core Feature
2030 \li Brief Description
2031 \row
2032 \li \l {Signal and Slots}
2033 \li Signals and slots are used for communication
2034 between objects.
2035 \row
2036 \li \l {Layout Management}
2037 \li The Qt layout system provides a simple
2038 and powerful way of specifying the layout
2039 of child widgets.
2040 \row
2041 \li \l {Drag and Drop}
2042 \li Drag and drop provides a simple visual
2043 mechanism which users can use to transfer
2044 information between and within applications.
2045 \endtable
2046 \1/
2047 \endcode
2048
2049 You can also make cells span several rows and columns. For
2050 example:
2051
2052 \badcode *
2053 /\1!
2054 \table
2055 \header
2056 \li {3,1} This header cell spans three columns,
2057 but only one row.
2058 \row
2059 \li {2, 1} This table cell spans two columns,
2060 but only one row
2061 \li {1, 2} This table cell spans only one column,
2062 but two rows.
2063 \row
2064 \li A regular table cell
2065 \li A regular table cell
2066 \endtable
2067 \1/
2068 \endcode
2069
2070 See also \l {header-command} {\\header}, \l {row-command} {\\row} and \l {li-command} {\\li}.
2071
2072 \target header-command
2073 \section1 \\header
2074
2075 The \\header command indicates that the following table cells are
2076 the current table's column headers.
2077
2078 The command can only be used within the \l{table-command}
2079 {\\table...\\endtable} commands. A header can contain several
2080 cells. A cell is created with the \l {li-command} {\\li} command.
2081
2082 A header cell's text is centered within the table cell and
2083 rendered using a bold font.
2084
2085 \badcode *
2086 /\1!
2087 \table
2088 \header
2089 \li Qt Core Feature
2090 \li Brief Description
2091 \row
2092 \li \l {Signal and Slots}
2093 \li Signals and slots are used for communication
2094 between objects.
2095 \endtable
2096 \1/
2097 \endcode
2098
2099 See also \l {table-command} {\\table}, \l {row-command} {\\row} and \l {li-command} {\\li}.
2100
2101 \target row-command
2102 \section1 \\row
2103
2104 The \\row command begins a new row in a table. The \l {li-command}
2105 {\\li items} that belong in the new row will immediately follow the
2106 \\row.
2107
2108 The command can only be used within the \l{table-command}
2109 {\\table...\\endtable} commands. A row can contain several
2110 cells. A cell is created with the \l {li-command} {\\li} command.
2111
2112 The background cell color of each row alternates between two
2113 shades of grey, making it easier to distinguish the rows from each
2114 other. The cells' contents is left aligned.
2115
2116 \badcode *
2117 /\1!
2118 \table
2119 \header
2120 \li Qt Core Feature
2121 \li Brief Description
2122 \row
2123 \li \l {Signal and Slots}
2124 \li Signals and slots are used for communication
2125 between objects.
2126 \row
2127 \li \l {Layout Management}
2128 \li The Qt layout system provides a simple
2129 and powerful way of specifying the layout
2130 of child widgets.
2131 \row
2132 \li \l {Drag and Drop}
2133 \li Drag and drop provides a simple visual
2134 mechanism which users can use to transfer
2135 information between and within applications.
2136 \endtable
2137 \1/
2138 \endcode
2139
2140 See also \l {table-command} {\\table}, \l {header-command}
2141 {\\header}, and \l {li-command} {\\li}.
2142
2143 \target value-command
2144 \section1 \\value
2145
2146 The \\value command starts the documentation of a C++ enum item.
2147
2148 The command's first argument is the value name. The value name may
2149 be preceded by an optional \e since clause enclosed in square
2150 brackets. The value description follows the value name. The description
2151 ends at the next blank line or \\value. The arguments are rendered in a
2152 table.
2153
2154 \note To include images in the \\value description, use the
2155 \l {inlineimage-command}{\\inlineimage} command.
2156
2157 Without a \e since clause, a \\value command could look like this:
2158
2159 \code
2160 \value QtInfoMsg A message generated by the qInfo() function.
2161 \endcode
2162
2163 The same command with a \e since clause would look like this:
2164
2165 \code
2166 \value [since 5.5] QtInfoMsg A message generated by the qInfo() function.
2167 \endcode
2168
2169 The documentation will be located in the associated class, header
2170 file or namespace documentation. See the \l {enum-command}
2171 {\\enum} documentation for an example.
2172
2173 \note Since Qt 5.4, \\value command can also be used outside the
2174 \l {enum-command} {\\enum} topic. In this case, QDoc renders a
2175 two-column table listing the constant name (taken as-is from the
2176 first argument) and its description. This can be used, for
2177 example, in \l {qmlproperty-command}{\\qmlproperty} topic for
2178 documenting acceptable values for a QML enumeration property.
2179
2180 See also \l {enum-command} {\\enum} and \l {omitvalue-command} {\\omitvalue}.
2181
2182 \target omitvalue-command
2183 \section1 \\omitvalue
2184
2185 The \\omitvalue command excludes a C++ enum item from the
2186 documentation.
2187
2188 The command's only mandatory argument is the name of the enum item
2189 that will be omitted. If the enum item is followed by a single-line
2190 description, that is also omitted.
2191
2192 See the \l {enum-command} {\\enum} documentation for an example.
2193
2194 See also \l {enum-command} {\\enum} and \l {value-command}
2195 {\\value} \l {since-command}{\\since}
2196
2197 \target list-command
2198 \section1 \\list
2199
2200 The \\list and \\endlist commands delimit a list of items.
2201
2202 Create each list item with the \l {li-command} {\\li} command. A
2203 list always contains one or more items. Lists can be nested. For
2204 example:
2205
2206 \badcode *
2207 /\1!
2208 \list
2209 \li Qt Reference Documentation: Getting Started
2210 \list
2211 \li How to Learn Qt
2212 \li Installation
2213 \list
2214 \li Qt/X11
2215 \li Qt/Windows
2216 \li Qt/Mac
2217 \li Qt/Embedded
2218 \endlist
2219 \li Tutorial and Examples
2220 \endlist
2221 \endlist
2222 \1/
2223 \endcode
2224
2225 The \\list command takes an optional argument providing
2226 alternative appearances for the list items.
2227
2228 \badcode *
2229 /\1!
2230 \list
2231 \li How to Learn Qt
2232 \li Installation
2233 \li Tutorial and Examples
2234 \endlist
2235 \1/
2236 \endcode
2237
2238 If you provide 'A' as an argument to the \\list command, the
2239 bullets are replaced with characters in alphabetical order:
2240
2241 \list A
2242 \li How to Learn Qt
2243 \li Installation
2244 \li Tutorial and Examples
2245 \endlist
2246
2247 If you replace 'A' with '1', the list items are numbered in
2248 ascending order:
2249
2250 \list 1
2251 \li How to Learn Qt
2252 \li Installation
2253 \li Tutorial and Examples
2254 \endlist
2255
2256 If you provide 'i' as the argument, the bullets are replaced with
2257 roman numerals:
2258
2259 \list i
2260 \li How to Learn Qt
2261 \li Installation
2262 \li Tutorial and Examples
2263 \endlist
2264
2265 Finally, you can make the list items appear with roman numbers
2266 following in ascending order if you provide 'I' as the optional
2267 argument:
2268
2269 \list I
2270 \li How to Learn Qt
2271 \li Installation
2272 \li Tutorial and Examples
2273 \endlist
2274
2275 You can also make the listing start at any character or number by
2276 simply provide the number or character you want to start at. For
2277 example:
2278
2279 \badcode *
2280 /\1!
2281 \list G
2282 \li How to Learn Qt
2283 \li Installation
2284 \li Tutorial and Examples
2285 \endlist
2286 \1/
2287 \endcode
2288
2289 See also \l {li-command} {\\li}.
2290
2291 \target li-command
2292 \section1 \\li (table cell, list item)
2293
2294 The \\li command marks a table cell or a list item. This command
2295 is only used in \l{table-command} {tables} and \l{list-command}
2296 {lists}.
2297
2298 It considers everything as its argument until the next \\li command, until the
2299 next \l {table-command} {\\endtable}, or \l {list-command} {\\endlist}
2300 command. See \l {table-command} {\\table} and \l {list-command} {\\list}
2301 for examples.
2302
2303 If the command is used within a table, you can also specify
2304 how many rows or columns the item should span.
2305
2306 \badcode *
2307 /\1!
2308 \table
2309 \header
2310 \li {3,1} This header cell spans three columns
2311 but only one row.
2312 \row
2313 \li {2, 1} This table item spans two columns
2314 but only one row
2315 \li {1, 2} This table item spans only one column,
2316 but two rows.
2317 \row
2318 \li A regular table item
2319 \li A regular table item
2320 \endtable
2321 \1/
2322 \endcode
2323
2324 If not specified, the item will span one column and one row.
2325
2326 See also \l {table-command} {\\table}, \l {header-command}
2327 {\\header}, and \l {list-command} {\\list}.
2328
2329*/
2330
2331
2332/*!
2333 \page 11-qdoc-commands-specialcontent.html
2334 \previouspage Tables and Lists
2335 \nextpage Miscellaneous
2336
2337 \title Special Content
2338
2339 The document contents commands identify parts of the documentation,
2340 parts with a special rendering, conceptual meaning or
2341 function.
2342
2343 \target quotation-command
2344 \section1 \\quotation
2345
2346 The \\quotation and \\endquotation commands delimit a long quotation.
2347
2348 The text in the delimited block is surrounded by
2349 \b{<blockquote>} and \b{</blockquote>} in the html output,
2350 e.g.:
2351
2352 \badcode *
2353 /\1!
2354 Although the prospect of a significantly broader market is
2355 good news for Firstlogic, the notion also posed some
2356 challenges. Dave Dobson, director of technology for the La
2357 Crosse, Wisconsin-based company, said:
2358
2359 \quotation
2360 As our solutions were being adopted into new
2361 environments, we saw an escalating need for easier
2362 integration with a wider range of enterprise
2363 applications.
2364 \endquotation
2365 \1/
2366 \endcode
2367
2368 The text in the \b{\\quotation} block will appear in the generated HTML as:
2369
2370 \badcode
2371 <blockquote>
2372 <p>As our solutions were being adopted into new environments,
2373 we saw an escalating need for easier integration with a wider
2374 range of enterprise applications.</p>
2375 </blockquote>
2376 \endcode
2377
2378 The built-in style sheet for most browsers will render the
2379 contents of the <blockquote> tag with left and right
2380 indentations. The example above would be rendered as:
2381
2382 \quotation
2383 As our solutions were being adopted into new
2384 environments, we saw an escalating need for easier
2385 integration with a wider range of enterprise
2386 applications.
2387 \endquotation
2388
2389 But you can redefine the \b{<blockquote>} tag in your style.css file.
2390
2391
2392 \target note-command
2393 \section1 \\note
2394
2395 The \\note command defines a new paragraph preceded by "Note:"
2396 in bold. The command takes a continuous paragraph as the argument,
2397 terminating after the end of the paragraph. The note command is only for
2398 shorter statements and not for longer multiline paragraphs.
2399
2400 Similar to the \l{warning-command}{\\warning} command, the note is for
2401 short and important statements. See
2402 \l{https://wiki.qt.io/Qt_Writing_Guidelines}{Qt Writing Guidelines} for
2403 usage information.
2404
2405 \target notranslate-command
2406 \section1 \\notranslate
2407
2408 The \\notranslate command indicates that its argument is \b not to be translated,
2409 when the generated output is passed to a language translation service.
2410
2411 Other commands (\qdoccmd {c}, \qdoccmd {tt}) have the same effect, but
2412 \\notranslate does not style its argument in any way.
2413
2414 This command was introduced in QDoc version 6.10.
2415
2416 \target brief-command
2417 \section1 \\brief
2418
2419 The \\brief command introduces a one-sentence description of
2420 any of the \l{Topic Commands}.
2421
2422 The brief text is used to introduce the documentation of the
2423 associated object, and in lists generated using the \l
2424 {generatelist-command} {\\generatelist} command and the \l
2425 {annotatedlist-command} {\\annotatedlist} command.
2426
2427 The brief text will be displayed in the documentation
2428 for that particular topic.
2429
2430 For example the boolean QWidget::isWindow property:
2431
2432 \badcode *
2433 /\1!
2434 \property QWidget::isActiveWindow
2435 \brief Whether this widget's window is the active window.
2436
2437 The active window is the window that contains the widget that
2438 has keyboard focus.
2439
2440 When popup windows are visible, this property is \c true
2441 for both the active window \e and the popup.
2442
2443 \sa activateWindow(), QApplication::activeWindow()
2444 \1/
2445 \endcode
2446
2447 and the QWidget::geometry property
2448
2449 \badcode *
2450 /\1!
2451 \property QWidget::geometry
2452 \brief The geometry of the widget relative to its parent and
2453 excluding the window frame.
2454
2455 When changing the geometry, the widget, if visible,
2456 receives a move event (moveEvent()) and/or a resize
2457 event (resizeEvent()) immediately.
2458
2459 ...
2460
2461 \sa frameGeometry(), rect(), ...
2462 \1/
2463 \endcode
2464
2465 When the \\brief command is used to describe a class, we recommend
2466 using a complete sentence like this:
2467
2468 \badcode
2469 The <classname> class is|provides|contains|specifies...
2470 \endcode
2471
2472 \warning Do not repeat your detailed description with the same sentence as
2473 the brief statement will be the first paragraph of the detailed
2474 description.
2475
2476 \badcode *
2477 /\1!
2478 \class PreviewWindow
2479 \brief The PreviewWindow class is a custom widget
2480 displaying the names of its currently set
2481 window flags in a read-only text editor.
2482
2483 The PreviewWindow class inherits QWidget. The widget
2484 displays the names of its window flags set with the
2485 setWindowFlags() function. It is also provided with a
2486 QPushButton that closes the window.
2487
2488 ...
2489
2490 \sa QWidget
2491 \1/
2492 \endcode
2493
2494 Using \\brief in a \l{namespace-command}{\\namespace}:
2495
2496 \badcode *
2497 /\1!
2498 \namespace Qt
2499
2500 \brief The Qt namespace contains miscellaneous identifiers
2501 used throughout the Qt library.
2502 \1/
2503 \endcode
2504
2505 Using \\brief in a \l{headerfile-command}{\\headerfile}:
2506
2507 \badcode *
2508 /\1!
2509 \headerfile <QtGlobal>
2510 \title Global Qt Declarations
2511
2512 \brief The <QtGlobal> header file provides basic
2513 declarations and is included by all other Qt headers.
2514
2515 \sa <QtAlgorithms>
2516 \1/
2517 \endcode
2518
2519 See also \l{property-command} {\\property}, \l{class-command}
2520 {\\class}, \l{namespace-command} {\\namespace} and
2521 \l{headerfile-command} {\\headerfile}.
2522
2523 \target legalese-command
2524 \section1 \\legalese
2525
2526 The \\legalese and \\endlegalese commands delimit a license agreement.
2527
2528 In the generated HTML, the delimited text is surrounded by a \b
2529 {<div class="LegaleseLeft">} and \b {</div>} tags.
2530
2531 An example of a license agreement enclosed in \\legalese
2532 and \\endlegalese:
2533
2534 \badcode *
2535 /\1!
2536 \legalese
2537 Copyright 1996 Daniel Dardailler.
2538
2539 Permission to use, copy, modify, distribute, and sell this
2540 software for any purpose is hereby granted without fee,
2541 provided that the above copyright notice appear in all
2542 copies and that both that copyright notice and this
2543 permission notice appear in supporting documentation, and
2544 that the name of Daniel Dardailler not be used in
2545 advertising or publicity pertaining to distribution of the
2546 software without specific, written prior permission. Daniel
2547 Dardailler makes no representations about the suitability of
2548 this software for any purpose. It is provided "as is"
2549 without express or implied warranty.
2550
2551 Modifications Copyright 1999 Matt Koss, under the same
2552 license as above.
2553 \endlegalese
2554 \1/
2555 \endcode
2556
2557 It will appear in the generated HTML as:
2558
2559 \badcode
2560 <div class="LegaleseLeft">
2561 <p>Copyright 1996 Daniel Dardailler.</p>
2562 <p>Permission to use, copy, modify, distribute, and sell
2563 this software for any purpose is hereby granted without fee,
2564 provided that the above copyright notice appear in all
2565 copies and that both that copyright notice and this
2566 permission notice appear in supporting documentation, and
2567 that the name of Daniel Dardailler not be used in
2568 advertising or publicity pertaining to distribution of the
2569 software without specific, written prior permission. Daniel
2570 Dardailler makes no representations about the suitability of
2571 this software for any purpose. It is provided "as is"
2572 without express or implied warranty.</p>
2573
2574 <p>Modifications Copyright 1999 Matt Koss, under the same
2575 license as above.</p>
2576 </div>
2577 \endcode
2578
2579 If the \\endlegalese command is omitted, QDoc will process the
2580 \\legalese command but considers the rest of the documentation
2581 page as the license agreement.
2582
2583 Ideally, the license text is located with the licensed code.
2584
2585 Elsewhere, the documentation identified as \e{\\legalese} command
2586 can be accumulated using \l {generatelist-command} {\\generatelist}
2587 with \c {legalese} as the argument. This is useful for generating
2588 an overview of the license agreements associated with the source
2589 code.
2590
2591 \note The output of the \c {\generatelist legalese} command includes
2592 the \\legalese texts in the current documentation project only. If
2593 the current documentation project depends on other modules, their
2594 license texts will not be listed.
2595
2596 \target warning-command
2597 \section1 \\warning
2598
2599 The \\warning command prepends "Warning:" to the command's
2600 argument, in bold font.
2601
2602 \badcode *
2603 /\1!
2604 Qt::HANDLE is a platform-specific handle type
2605 for system objects. This is equivalent to
2606 \c{void *} on Windows and macOS, and to
2607 \c{unsigned long} on X11.
2608
2609 \warning Using this type is not portable.
2610 \1/
2611 \endcode
2612*/
2613
2614
2615/*!
2616 \page 12-0-qdoc-commands-miscellaneous.html
2617 \previouspage Special Content
2618 \nextpage The QDoc Configuration File
2619
2620 \title Miscellaneous
2621
2622 These commands provide miscellaneous functions connected to the
2623 visual appearance of the documentation, and to the process of
2624 generating the documentation.
2625
2626 \target annotatedlist-command
2627 \section1 \\annotatedlist
2628
2629 The \\annotatedlist command expands to a list of the members of a
2630 group, each member listed with its \e {brief} text. Below is an
2631 example from the Qt Reference Documentation:
2632
2633 \badcode *
2634 /\1!
2635 ...
2636 \section1 Drag and Drop Classes
2637
2638 These classes deal with drag and drop and the necessary mime type
2639 encoding and decoding.
2640
2641 \annotatedlist draganddrop
2642 \1/
2643 \endcode
2644
2645 This generates a list of all the C++ classes and/or QML types in
2646 the \e{draganddrop} group. A C++ class or QML type in the
2647 \e{draganddrop} group will have \e{\\ingroup draganddrop} in its
2648 \e{\\class} or \e{\\qmltype} comment.
2649
2650 The group members are sorted in ascending order, based on
2651 user-visible name or title. Since QDoc 6.8, \\annotatedlist
2652 and \qdoccmd generatelist support also custom sorting.
2653
2654 See also \qdoccmd generatelist and \l {Sorting group members}.
2655
2656 \target cmakepackage-command
2657 \section1 \\cmakepackage
2658
2659 Use the \\cmakepackage command to add CMake package information to classes
2660 and namespaces. This information will then appear in a table at the top of
2661 the class or namespace documentation page. For example:
2662
2663 \badcode *
2664 /*!
2665 \namespace Foo
2666 \inheaderfile Bar
2667 \cmakepackage Baz
2668 \brief A namespace.
2669
2670 ...
2671 \1/
2672 \endcode
2673
2674 QDoc will output this as
2675
2676 \quotation
2677 \raw HTML
2678 <h1 class="title">Foo Namespace</h1>
2679 <p>A namespace. <a>More...</a></p>
2680 <div class="table"><table class="alignedsummary">
2681 <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;Bar&gt;</span></td></tr>
2682 <tr><td class="memItemLeft rightAlign topAlign"> CMake:</td><td class="memItemRight bottomAlign"> find_package(Baz REQUIRED)<br/>target_link_libraries(mytarget PRIVATE Baz::Baz)</td></tr>
2683 </table></div>
2684 \endraw
2685 \endquotation
2686
2687 \e{See also} \l{module-command}{\\module} and
2688 \l{cmakecomponent}{\\cmakecomponent}}
2689
2690 \target cmakecomponent-command
2691 \section1 \\cmakecomponent
2692
2693 Use the \\cmakecomponent command to add CMake component information to classes
2694 and namespaces. This information will then appear in a table at the top of
2695 the class or namespace documentation page. For example:
2696
2697 \badcode *
2698 /*!
2699 \namespace Foo
2700 \inheaderfile Bar
2701 \cmakecomponent Baz
2702 \brief A namespace.
2703
2704 ...
2705 \1/
2706 \endcode
2707
2708 QDoc will output this as
2709
2710 \quotation
2711 \raw HTML
2712 <h1 class="title">Foo Namespace</h1>
2713 <p>A namespace. <a>More...</a></p>
2714 <div class="table"><table class="alignedsummary">
2715 <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;Bar&gt;</span></td></tr>
2716 <tr><td class="memItemLeft rightAlign topAlign"> CMake:</td><td class="memItemRight bottomAlign"> find_package(Qt6 REQUIRED COMPONENTS Baz)<br/>target_link_libraries(mytarget PRIVATE Qt6::Baz)</td></tr>
2717 </table></div>
2718 \endraw
2719 \endquotation
2720
2721 \e{See also} \l{module-command}{\\module} and
2722 \l{cmakepackage}{\\cmakepackage}}
2723
2724 \target cmaketargetitem-command
2725 \section1 \\cmaketargetitem
2726
2727 Use the \\cmaketargetitem command to override the \e {item} part of the
2728 CMake \c{target_link_libraries} information that's added to classes and
2729 namespaces. The command must be used in conjunction with the
2730 \l{module-command}{\\module} and \l{cmakecomponent}{\\cmakecomponent}}
2731 commands. For example:
2732
2733 \badcode *
2734 /*!
2735 \namespace Foo
2736 \inheaderfile Bar
2737 \cmakecomponent Baz
2738 \cmaketargetitem Qt6::BazPrivate
2739 \brief A namespace.
2740
2741 ...
2742 \1/
2743 \endcode
2744
2745 QDoc will output this as
2746
2747 \quotation
2748 \raw HTML
2749 <h1 class="title">Foo Namespace</h1>
2750 <p>A namespace. <a>More...</a></p>
2751 <div class="table"><table class="alignedsummary">
2752 <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;Bar&gt;</span></td></tr>
2753 <tr><td class="memItemLeft rightAlign topAlign"> CMake:</td><td class="memItemRight bottomAlign"> find_package(Qt6 REQUIRED COMPONENTS Baz)<br/>target_link_libraries(mytarget PRIVATE Qt6::BazPrivate)</td></tr>
2754 </table></div>
2755 \endraw
2756 \endquotation
2757
2758 \e{See also} \l{module-command}{\\module} and
2759 \l{cmakecomponent}{\\cmakecomponent}}
2760
2761
2762 \target qtcmakepackage-command
2763 \section1 \\qtcmakepackage
2764
2765 Use the \\qtcmakepackage command to add CMake package information to classes
2766 and namespaces. This information will then appear in a table at the top of
2767 the class or namespace documentation page. For example:
2768
2769 \badcode *
2770 /*!
2771 \namespace Foo
2772 \inheaderfile Bar
2773 \qtcmakepackage Baz
2774 \brief A namespace.
2775
2776 ...
2777 \1/
2778 \endcode
2779
2780 QDoc will output this as
2781
2782 \quotation
2783 \raw HTML
2784 <h1 class="title">Foo Namespace</h1>
2785 <p>A namespace. <a>More...</a></p>
2786 <div class="table"><table class="alignedsummary">
2787 <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;Bar&gt;</span></td></tr>
2788 <tr><td class="memItemLeft rightAlign topAlign"> CMake:</td><td class="memItemRight bottomAlign"> find_package(Qt6 REQUIRED COMPONENTS Baz)</td></tr>
2789 </table></div>
2790 \endraw
2791 \endquotation
2792
2793
2794 \target qtcmaketargetitem-command
2795 \section1 \\qtcmaketargetitem
2796
2797 Use the \\qtcmaketargetitem command to override the \e {item} part of the
2798 CMake \c{target_link_libraries} information that's added to classes and
2799 namespaces. The command must be used in conjunction with the
2800 \l{module-command}{\\module} and \l{qtcmakepackage}{\\qtcmakepackage}}
2801 commands.
2802
2803 \e{See also} \l{module-command}{\\module} and
2804 \l{qtcmakepackage}{\\qtcmakepackage}}
2805
2806
2807 \target generatelist-command
2808 \section1 \\generatelist
2809
2810 The \\generatelist command expands to a list of links to the
2811 documentation entities grouped with an \l {ingroup-command}
2812 {\\ingroup} command or entities that match one of the arguments
2813 listed below. An example from the Qt Reference Documentation:
2814
2815 \badcode *
2816 /\1!
2817 \page classes.html
2818 \title All Classes
2819
2820 For a shorter list that only includes the most
2821 frequently used classes, see \l{Qt's Main Classes}.
2822
2823 \generatelist classes Q
2824 \1/
2825 \endcode
2826
2827 This generates the \e {All Classes} page. The command accepts the
2828 following arguments:
2829
2830 \section2 \c {<group-name>}
2831
2832 With a group name as the only argument, QDoc lists all entities that
2833 use the \c {\ingroup <group-name>} command.
2834
2835 \section3 Sorting group members
2836
2837 When generating a list of group members, they are sorted in ascending
2838 order, based on user-visible name or title. Since QDoc 6.8, the default
2839 sort order can be modified:
2840
2841 \badcode
2842 \generatelist [descending] changelogs
2843 \endcode
2844
2845 Assuming the \e changelogs group consists of pages
2846 detailing changes in different versions, this generates the
2847 list in descending order (newest version first).
2848
2849 \section4 Sort key
2850
2851 Since QDoc 6.8, a custom sort key can be assigned to one or
2852 more group members using the \qdoccmd meta command:
2853
2854 \badcode
2855 \meta sortkey {sort key}
2856 \endcode
2857
2858 Sorting (ascending or descending) is then done based on
2859 these key(s), rather than user-visible titles.
2860
2861 \note Any group member with a sort key is listed \e before
2862 members without a key (in the default ascending order). This
2863 allows raising individual group member(s) to the top of the
2864 list.
2865
2866 \target table example
2867 \section2 \c annotatedclasses
2868
2869 The \c annotatedclasses argument provides a table containing the
2870 names of all the classes, and a description of each class. Each
2871 class name is a link to the class's reference documentation. For
2872 example:
2873
2874 \table
2875 \row
2876 \li QDial
2877 \li Rounded range control (like a speedometer or potentiometer)
2878 \row
2879 \li QDialog
2880 \li The base class of dialog windows
2881 \row
2882 \li QDir
2883 \li Access to directory structures and their contents
2884 \endtable
2885
2886 A C++ class is documented with the \l {class-command} {\\class}
2887 command. The annotation for the class is taken from the argument
2888 of the class comment's \l {brief-command} {\\brief} command.
2889
2890 \section2 \c annotatedexamples
2891
2892 The \c annotatedexamples argument provides a complete list of all
2893 examples as a set of tables containing the titles of all the
2894 examples, and a description of each example. Each title is a
2895 link to the example's documentation.
2896
2897 A separate table for each module (that has documented examples)
2898 is generated, provided that the module has defined a
2899 navigation.landingpage configuration variable. The \e landingpage
2900 variable is used as a title for a header that precedes each table.
2901
2902 \section2 \c annotatedattributions
2903
2904 The \c annotatedattributions argument provides a complete list of all
2905 attributions as a set of tables containing the titles of all the
2906 attributions, and a description of each attribution. Each title is a
2907 link to the attribution's page.
2908
2909 A separate table for each module (that has attributions)
2910 is generated, provided that the module has defined a
2911 navigation.landingpage configuration variable. The \e landingpage
2912 variable is used as a title for a header that precedes each table.
2913
2914 \target list example
2915 \section2 \c {classes <prefix>}
2916
2917 The \c classes argument provides a complete alphabetical list of
2918 the classes. The second argument, \c{<prefix>}, is the common
2919 prefix for the class names. The class names will be sorted on the
2920 character that follows the common prefix. e.g. The common prefix
2921 for the Qt classes is \c Q. The common prefix argument is
2922 optional. If no common prefix is provided, the class names will
2923 be sorted on their first character.
2924
2925 Each class name becomes a link to the class's reference
2926 documentation. This command is used to generate the
2927 \e {All Classes} page this way:
2928
2929 \badcode *
2930 /\1!
2931 \page classes.html
2932 \title All Classes
2933 \ingroup classlists
2934
2935 \brief Alphabetical list of classes.
2936
2937 This is a list of all Qt classes. For classes that
2938 have been deprecated, see the \l{Obsolete Classes}
2939 list.
2940
2941 \generatelist classes Q
2942 \1/
2943 \endcode
2944
2945 A C++ class is documented with the \l {class-command} {\\class}
2946 command.
2947
2948 \section2 \c classesbymodule
2949
2950 When this argument is used, a second argument is required, which
2951 specifies the module whose classes are to be listed. QDoc
2952 generates a table containing those classes. Each class is listed
2953 with the text of its \l{brief-command} {\\brief} command.
2954
2955 For example, this command can be used on a module page as follows:
2956
2957 \badcode *
2958 /\1!
2959 \page phonon-module.html
2960 \module Phonon
2961 \title Phonon Module
2962 \ingroup modules
2963
2964 \brief Contains namespaces and classes for multimedia functionality.
2965
2966 \generatelist{classesbymodule Phonon}
2967
2968 ...
2969 \1/
2970 \endcode
2971
2972 Each class that is a member of the specified module must be marked
2973 with the \l {inmodule-command} {\\inmodule} command in its \\class
2974 comment.
2975
2976 \section2 \c qmltypesbymodule
2977
2978 Similar to \c classesbymodule argument, but used for listing the
2979 QML types (excluding QML value types) from the QML module specified
2980 with the second argument.
2981
2982 \note Support for this argument was introduced in QDoc 5.6.
2983
2984 \section2 \c qmlvaluetypesbymodule
2985
2986 Similar to \c qmltypesbymodule argument, but lists QML value
2987 types instead.
2988
2989 \note Support for this argument was introduced in QDoc 6.7.
2990
2991 \section2 \c functionindex
2992
2993 The \c functionindex argument provides a complete alphabetical
2994 list of all the documented member functions. It is normally used
2995 only to generate the \e {Qt function index} page
2996 this way:
2997
2998 \badcode *
2999 /\1!
3000 \page functions.html
3001 \title All Functions
3002 \ingroup funclists
3003
3004 \brief All documented Qt functions listed alphabetically with a
3005 link to where each one is declared.
3006
3007 This is the list of all documented member functions and global
3008 functions in the Qt API. Each function has a link to the
3009 class or header file where it is declared and documented.
3010
3011 \generatelist functionindex
3012 \1/
3013 \endcode
3014
3015 \section2 \c legalese
3016
3017 The \c legalese argument tells QDoc to generate a list of licenses in
3018 the current documentation project. Each license is identified using
3019 the \l {legalese-command} {\\legalese} command.
3020
3021 \section2 \c overviews
3022
3023 The \c overviews argument is used to tell QDoc to generate a list
3024 by concatenating the contents of all the \l {group-command}
3025 {\\group} pages. Qt uses it to generate the \e {overviews} page
3026 this way:
3027
3028 \badcode *
3029 /\1!
3030 \page overviews.html
3031
3032 \title All Overviews and HOWTOs
3033
3034 \generatelist overviews
3035 \1/
3036 \endcode
3037
3038 \section2 \c attributions
3039
3040 The \c attributions argument is used to tell QDoc to generate a list
3041 of attributions in the documentation.
3042
3043 \section2 \c related
3044
3045 The \c related argument is used in combination with the \l
3046 {group-command} {\\group} and \l {ingroup-command} {\\ingroup}
3047 commands to list all the overviews related to a specified
3048 group. For example, the page for the \e {Programming with Qt}
3049 page is generated this way:
3050
3051 \badcode *
3052 /\1!
3053 \group qt-basic-concepts
3054 \title Programming with Qt
3055
3056 \brief The basic architecture of the Qt cross-platform application and UI framework.
3057
3058 Qt is a cross-platform application and UI framework for
3059 writing web-enabled applications for desktop, mobile, and
3060 embedded operating systems. This page contains links to
3061 articles and overviews explaining key components and
3062 techniuqes used in Qt development.
3063
3064 \generatelist {related}
3065 \1/
3066 \endcode
3067
3068 Each page listed on this group page contains the command:
3069
3070 \code
3071 \ingroup qt-basic-concepts
3072 \endcode
3073
3074 See also \qdoccmd {annotatedlist}.
3075
3076 \target if-command
3077 \section1 \\if
3078
3079 The \\if command and the corresponding \\endif command
3080 enclose parts of a QDoc comment that only will be included if
3081 the condition specified by the command's argument is true.
3082
3083 The command reads the rest of the line and parses it as an C++ #if
3084 statement.
3085
3086 \badcode *
3087 /\1!
3088 \if defined(opensourceedition)
3089
3090 \note This edition is for the development of
3091 \l{Qt Open Source Edition} {Free and Open Source}
3092 software only; see \l{Qt Commercial Editions}.
3093
3094 \endif
3095 \1/
3096 \endcode
3097
3098 This QDoc comment will only be rendered if the \c
3099 opensourceedition preprocessor symbol is defined, and specified in
3100 the \l {defines-variable} {defines} variable in the configuration
3101 file to make QDoc process the code within #ifdef and #endif:
3102
3103 \badcode
3104 defines = opensourceedition
3105 \endcode
3106
3107 You can also define the preprocessor symbol manually on the
3108 command line. For more information see the documentation of the \l
3109 {defines-variable} {defines} variable.
3110
3111 See also \l{endif-command} {\\endif}, \l{else-command} {\\else},
3112 \l {defines-variable} {defines} and \l {falsehoods-variable}
3113 {falsehoods}.
3114
3115 \target endif-command
3116 \section1 \\endif
3117
3118 The \\endif command and the corresponding \\if command
3119 enclose parts of a QDoc comment that will be included if
3120 the condition specified by the \l {if-command} {\\if} command's
3121 argument is true.
3122
3123 For more information, see the documentation of the \l {if-command}
3124 {\\if} command.
3125
3126 See also \l{if-command} {\\if}, \l{else-command} {\\else}, \l
3127 {defines-variable} {defines} and \l {falsehoods-variable}
3128 {falsehoods}.
3129
3130 \target else-command
3131 \section1 \\else
3132
3133 The \\else command specifies an alternative if the
3134 condition in the \l {if-command} {\\if} command is false.
3135
3136 The \\else command can only be used within \l {if-command}
3137 {\\if...\\endif} commands, but is useful when there is only two
3138 alternatives.
3139
3140 \target include-command
3141 \section1 \\include
3142
3143 The \\include command sends all or part of the file specified by
3144 its first argument to the QDoc input stream to be processed as a
3145 QDoc comment snippet.
3146
3147 The command is useful when some snippet of commands or text is to
3148 be used in multiple places in the documentation. Use the \\include
3149 command wherever you want to insert a snippet into the documentation.
3150 The file containing the snippet to include, must be located under the
3151 path(s) listed in the \l{sourcedirs-variable}{sourcedirs} or
3152 \l{exampledirs-variable}{exampledirs} QDoc configuration variable.
3153 It can be either any source file parsed by QDoc (or even the same one
3154 where \\include command is used), or any other text file. To store
3155 snippets in a separate file that is not meant to be parsed by QDoc,
3156 use a file extension that is not listed in
3157 \l{sources.fileextensions-variable}{sources.fileextensions};
3158 for example, \c .qdocinc.
3159
3160 The command can have one or more arguments. The first
3161 argument is always a file name. The contents of the file must be
3162 QDoc input, in other words, a sequence of QDoc commands and text, but
3163 without the enclosing QDoc comment \c{/}\c{*!} ... \c{*}\c{/} delimiters.
3164 If you want to include the entire named file, leave the second argument
3165 empty. If you want to include only part of the file, see the
3166 \l{2-argument-form}{two argument form} below. Here is an example
3167 of the one argument form:
3168
3169 \badcode *
3170 /\1!
3171 \page corefeatures.html
3172 \title Core Features
3173
3174 \include examples/signalandslots.qdocinc
3175 \include examples/objectmodel.qdocinc
3176 \include examples/layoutmanagement.qdocinc
3177 \1/
3178 \endcode
3179
3180
3181 \target 2-argument-form
3182 \section2 \\include filename snippet-identifier
3183
3184 It is a waste of time to make a separate \c .qdocinc file for every
3185 QDoc include snippet you want to use in multiple places in the
3186 documentation, especially given that you probably have to put the
3187 copyright/license notice in every one of these files. If you
3188 have multiple snippets to be included, you can put them all in a
3189 single file and surround each one with:
3190
3191 \badcode
3192 //! [snippet-id1]
3193
3194 QDoc commands and text...
3195
3196 //! [snippet-id1]
3197
3198 //! [snippet-id2]
3199
3200 More QDoc commands and text...
3201
3202 //! [snippet-id2]
3203 \endcode
3204
3205 Then you can use the two-argument form of the command:
3206
3207 \badcode
3208 \include examples/signalandslots.qdocinc snippet-id2
3209 \include examples/objectmodel.qdocinc another-snippet-id
3210 \endcode
3211
3212 The sequence of QDoc commands and text found between the two tags
3213 with the same name as the second argument is sent to the QDoc input
3214 stream. You can even have nested snippets.
3215
3216 \note Snippet identifiers work also within documentation comment
3217 (\beginqdoc .. \endqdoc) blocks, so it's not necessary to use a
3218 separate \c .qdocinc file. When processing a comment block, QDoc
3219 removes any \c {//!} comment lines from the generated output.
3220
3221 \section2 Extra arguments
3222
3223 Since QDoc 6.3, any further arguments passed to the \\include command
3224 are used for injecting strings into the included content. To inject a
3225 string to a specific location in the content, add a backslash followed
3226 by a digit (1..9). The digits correspond with the order of the argument
3227 list. Enclose arguments in curly braces to ensure that QDoc renders the
3228 entire argument, including possible whitespace characters, as you expect.
3229
3230 \important Each additional argument (including the snippet ID) must be
3231 enclosed in braces. If you want to include the entire file,
3232 use an empty snippet ID: \c {{}}.
3233
3234 For example, given the following snippet in a file \c includes.qdocinc:
3235
3236 \badcode
3237 //! [usage]
3238 To enable \e{\1}, select \uicontrol {\2} > \uicontrol Enable.
3239 //! [usage]
3240 \endcode
3241
3242 Then, the following \\include line:
3243
3244 \badcode
3245 \include includes.qdocinc {usage} {detailed output} {Verbose}
3246 \endcode
3247
3248 Renders
3249 \quotation
3250 To enable \e {detailed output}, select \uicontrol {Verbose} >
3251 \uicontrol Enable.
3252 \endquotation
3253
3254 \target meta-command
3255 \section1 \\meta
3256
3257 The \\meta command is used for adding metadata to documentation.
3258 The command has two arguments: the first argument is the name of the
3259 metadata attribute, and the second argument is the value for the attribute.
3260 Each argument should be enclosed in curly brackets, as shown in this
3261 example:
3262
3263 \badcode *
3264 /\1!
3265 \example demos/coffee
3266 \title Coffee Machine
3267 \brief A Qt Quick application with a state-based custom user interface.
3268
3269 \meta {tags} {quick,embedded,states,touch}
3270 \meta {category} {Application Examples}
3271 \1/
3272 \endcode
3273
3274 A number of metadata attributes have a specific purpose:
3275
3276 \b {Example Metadata}
3277
3278 Another use for \\meta command is to include metadata (tags) in
3279 \l {example-command}{\\example} documentation. By default, QDoc
3280 generates example tags based on the example's \l {title-command}{\\title}
3281 and module name. These tags are displayed in Qt Creator's Welcome mode,
3282 helping users navigate the list of examples.
3283
3284 Additional tags can be created with \c {\meta {tag} {tag1}}
3285 or \c {\meta {tags} {tag1,[tag2,...]}}.
3286 For example:
3287
3288 \badcode *
3289 /\1!
3290 \example helloworld
3291 \title Hello World Example
3292 \meta {tags} {tutorial,basic}
3293 \1/
3294 \endcode
3295
3296 This would result in the following tags: \e {tutorial,basic,hello,world}.
3297 Common words such as \e example are ignored.
3298
3299 \b {Excluding Examples}
3300
3301 Marking an example \e broken will exclude it from the generated manifest
3302 file, effectively removing it from Qt Creator's Welcome mode.
3303
3304 \badcode
3305 \meta {tag} {broken}
3306 \endcode
3307
3308 \b {Example Install Paths}
3309
3310 The \\meta command combined with an argument \c installpath specifies the
3311 location of an installed example. This value overrides the one that is set
3312 using the \c examplesinstallpath configuration variable.
3313
3314 \badcode *
3315 /\1!
3316 \example helloworld
3317 \title Hello World Example
3318 \meta {installpath} {tutorials}
3319 \1/
3320 \endcode
3321
3322 See also \l {examplesinstallpath}.
3323
3324 \b {Status}
3325
3326 A \c status argument for the \\meta command adds a custom status description
3327 for a \l {class-command}{\\class} or a \l {qmltype-command}{\\qmltype}. This
3328 description will then appear in a table at the top of the type reference page.
3329
3330 \badcode *
3331 /\1!
3332 \class QNativeInterface::QAndroidApplication
3333 \meta {status} {Android-specific}
3334 \1/
3335 \endcode
3336
3337 See also \l {Status}{status-related commands}.
3338
3339 \target noautolist-command
3340 \section1 \\noautolist
3341
3342 The \\noautolist command indicates that the annotated list of C++
3343 classes or QML types, which is automatically generated at the
3344 bottom of the C++ or QML module page should be omitted, because
3345 the classes or types have been listed manually. This command can
3346 also be used with the \l {group-command}{\\group} command to omit
3347 the list of group members, when they are listed manually.
3348
3349 The command must stand on its own line. See \l {Qt Quick Controls QML Types}
3350 for an example. The page is generated from \c {qtquickcontrols2-qmlmodule.qdoc}.
3351 There you will find a QDoc comment containing the \c{\qmlmodule} command for
3352 the QtQuick.Controls module. The same comment contains a \c {\noautolist}
3353 command to disable automatic list generation, and a \l {generatelist-command}
3354 {\\generatelist} to list the QML types in a specific section of the document.
3355
3356 This command was introduced in QDoc 5.6.
3357
3358 Since Qt 5.10, this command can be applied also to \l{example-command}
3359 {\\example} documentation, where it causes the automatically generated
3360 list of files and images belonging to an example project to be omitted.
3361
3362 \target omit-command
3363 \section1 \\omit
3364
3365 The \\omit command and the corresponding \\endomit command
3366 delimit parts of the documentation that you want QDoc to skip. For
3367 example:
3368
3369 \badcode *
3370 /\1!
3371 \table
3372 \row
3373 \li Basic Widgets
3374 \li Basic GUI widgets such as buttons, comboboxes
3375 and scrollbars.
3376
3377 \omit
3378 \row
3379 \li Component Model
3380 \li Interfaces and helper classes for the Qt
3381 Component Model.
3382 \endomit
3383
3384 \row
3385 \li Database Classes
3386 \li Database related classes, e.g. for SQL databases.
3387 \endtable
3388 \1/
3389 \endcode
3390
3391 \target raw-command
3392 \section1 \\raw (avoid!)
3393
3394 The \\raw command and the corresponding
3395 \\endraw command delimit a block of raw mark-up language code.
3396
3397 \warning Avoid using this command if possible. If you are trying to
3398 generate special table or list behavior, try to get the behavior you want
3399 using the \l {span-command} {\\span} and \l {div-command} {\\div}
3400 commands in your \l {table-command} {\\table} or \l {list-command}
3401 {\\list}.
3402
3403 The command takes an argument specifying the code's format.
3404
3405 QDoc generates the given code only when generating the format that
3406 was specified by the user.
3407
3408 For example, "\\raw HTML" will only generate code when QDoc
3409 generates HTML documentation.
3410
3411 \note You can often achieve the intended purpose by using QDoc commands,
3412 while reducing the chance of mistakes or content becoming unmaintained.
3413
3414 \target sincelist-command
3415 \section1 \\sincelist
3416
3417 The \\sincelist command expands to a detailed breakdown of new
3418 inclusions to the documented API in a specified version. Example
3419 usage:
3420
3421 \badcode * \QtMajorVersion \QtMinorVersion \QtVer
3422 /\1!
3423 \page newclasses\2\3.html
3424 \title New Classes and Functions in \4
3425 \brief A comprehensive list of new classes and functions in \4.
3426
3427 \sincelist \4
3428 \1/
3429 \endcode
3430
3431 \\sincelist takes a single argument, a version string. The generated
3432 output includes all functionality that is marked with a
3433 \l {since-command}{\\since} command or a \l {since clause} matching
3434 the version string.
3435
3436 \target unicode-command
3437 \section1 \\unicode
3438
3439 The \\unicode command allows you to insert an arbitrary Unicode
3440 character in the document.
3441
3442 The command takes an argument specifying the character as an
3443 integer. By default, base 10 is assumed, unless a '0x' or '0'
3444 prefix is specified (for base 16 and 8, respectively).
3445*/