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