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