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