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-topiccmds.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page 13-qdoc-commands-topics.html
6
\previouspage Command Index
7
\nextpage Context Commands
8
9
\title Topic Commands
10
11
A topic command tells QDoc which source code element is being
12
documented. Some topic commands allow you to create documentation
13
pages that aren't tied to any underlying source code element.
14
15
When QDoc processes a QDoc comment, it tries to connect the
16
comment to an element in the source code by first looking for a
17
topic command that names the source code element. If there is no
18
topic command, QDoc tries to connect the comment to the source
19
code element that immediately follows the comment. If it can't do
20
either of these and if there is no topic command that indicates
21
the comment does not have an underlying source code element (e.g.
22
\l{page-command} {\\page}), then the comment is discarded.
23
24
\target topic argument
25
26
The name of the entity being documented is usually the only
27
argument for a topic command. Use the complete name. Sometimes
28
there can be a second parameter in the argument. See e.g. \l
29
{page-command} {\\page}.
30
31
\code
32
\enum QComboBox::InsertPolicy
33
\endcode
34
35
The \l {fn-command} {\\fn} command is a special case. For the \l
36
{fn-command} {\\fn} command, use the function's signature
37
including the class qualifier.
38
39
\code
40
\fn void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
41
\endcode
42
43
A topic command can appear anywhere in a comment but must stand
44
alone on its own line. It is good practice is to let the topic command
45
be the first line of the comment. If the argument spans several
46
lines, make sure that each line (except the last one) is ended
47
with a backslash. Moreover, QDoc counts parentheses, which means
48
that if it encounters a '(' it considers everything until the
49
closing ')' as its argument.
50
51
If a topic command is repeated with different arguments, the
52
same documentation will appear for both the units.
53
54
\badcode *
55
/\1!
56
\fn void PreviewWindow::setWindowFlags()
57
\fn void ControllerWindow::setWindowFlags()
58
59
Sets the widgets flags using the QWidget::setWindowFlags()
60
function.
61
62
Then runs through the available window flags, creating a text
63
that contains the names of the flags that matches the flags
64
parameter, displaying the text in the widgets text editor.
65
\1/
66
\endcode
67
68
The \c PreviewWindow::setWindowFlags() and \c
69
ControllerWindow::setWindowFlags() functions will get the same
70
documentation.
71
72
\section2 Nomenclature for files generated by topic commands
73
74
For many topic commands, such as \l {page-command}{\\page}, QDoc
75
generates a file when processing the documentation.
76
77
QDoc normalizes the name of each file before writing it to disk.
78
The following operations are performed:
79
80
\list
81
\li All sequences of non alphanumeric characters are replaced with a hyphen, '-'.
82
\li All uppercase letters are replaced with their lowercase equivalent.
83
\li All trailing hyphens are removed.
84
\endlist
85
86
For example, the following command generates a file named
87
\c{this-generates-a-file-and-writes-it-to-disk.html}:
88
89
\badcode
90
\page this_generates_a_file_(and_writes_it_to_DISK)-.html
91
\endcode
92
93
As the example shows, the name that is given to the file in the
94
command might differ from the name of the actual file that is
95
written to disk.
96
97
\section3 Prefixes and Suffixes for generated files
98
99
When QDoc generates a file, it may add a prefix, a suffix, or both,
100
depending on the element that the file will document.
101
102
The table below shows what those prefixes and suffixes are for
103
various elements.
104
105
\table
106
\header
107
\li Element
108
\li Prefix
109
\li Suffix
110
\li Command
111
\row
112
\li QML Modules
113
\li None
114
\li "-qmlmodule"
115
\li \l {qmlmodule-command}{\\qmlmodule}
116
\row
117
\li Modules
118
\li None
119
\li "-module"
120
\li \l {module-command}{\\module}
121
\row
122
\li Examples
123
\li The project name, as given by the \l
124
{project-variable}{project configuration variable},
125
followed by a hyphen.
126
\li "-example"
127
\li \l {example-command}{\\example}
128
\row
129
\li QML Types
130
\li The output prefix for QML, as given by the \l
131
{outputprefixes-variable}{outputprefixes configuration
132
variable}.
133
134
If the module that contains this type is known to QDoc,
135
the module name is added as a prefix, followed by the QML
136
output suffix, as defined by the \l
137
{outputsuffixes-variable}{outputsuffixes configuration
138
variable} and a hyphen.
139
\li None
140
\li \l {qmltype-command}{\\qmltype}
141
\endtable
142
143
\target class-command
144
\section1 \\class
145
146
The \\class command is for documenting a C++ \e class, a C/C++
147
\e struct, or a \e union. The argument is the complete, qualified
148
name of the class. The command tells QDoc that a class is part of
149
the public API, and lets you enter a detailed description.
150
151
\badcode *
152
/\1!
153
\class QMap::iterator
154
\inmodule QtCore
155
156
\brief The QMap::iterator class provides an STL-style
157
non-const iterator for QMap and QMultiMap.
158
159
QMap features both \l{STL-style iterators} and
160
\l{Java-style iterators}. The STL-style iterators ...
161
\1/
162
\endcode
163
164
The HTML documentation for the named class is written to a
165
\c{.html} file named from the class name, in lower case, and with
166
the double colon qualifiers replaced with '-'. For example, the
167
documentation for the \c QMap::iterator class is written to \c
168
qmap-iterator.html.
169
170
The file contains the class description from the \\class comment,
171
plus the documentation generated from QDoc comments for all the
172
class members: a list of the class's types, properties,
173
functions, signals, and slots.
174
175
In addition to the detailed description of the class, the \\class
176
comment typically contains an \l {inmodule-command} {\\inmodule}
177
command, as well as a \l {brief-command} {\\brief} description.
178
Here is a very simple example:
179
180
\badcode *
181
/\1!
182
\class PreviewWindow
183
\inmodule CustomWidgets
184
\brief The PreviewWindow class is a custom widget.
185
displaying the names of its currently set
186
window flags in a read-only text editor.
187
188
\ingroup miscellaneous
189
190
The PreviewWindow class inherits QWidget. The widget
191
displays the names of its window flags set with the \l
192
{function} {setWindowFlags()} function. It is also
193
provided with a QPushButton that closes the window.
194
195
...
196
197
\sa QWidget
198
\1/
199
\endcode
200
201
The way QDoc renders this \\class depends on your \c {style.css}
202
file.
203
204
\target concept-command
205
\section1 \\concept
206
207
The \\concept command creates a separate page for a C++20 concept
208
and aggregates the documented types and functions whose template
209
constraints reference it. The argument is the concept's
210
fully-qualified name, matching the name Clang reports for the
211
declaration. Concepts at file scope use their bare name; concepts
212
inside a namespace need the full qualified name, such as
213
\c {algorithms::Ordered}.
214
215
A type or function joins a concept's page automatically. When QDoc
216
parses a documented declaration, it inspects the declaration's
217
constraints and registers the declaration with the concepts they
218
reference. No \\ingroup or \\inmodule-style command is required on
219
the constrained item itself.
220
221
QDoc recognises the three syntactic forms of C++20 constraints:
222
223
\list
224
\li An explicit \c {requires} clause, whether it appears in the
225
template head (\c {template <typename T> requires Ordered<T>})
226
or trailing the function signature.
227
\li A constrained \c {auto} parameter
228
(\c {void sort(Ordered auto& range)}).
229
\li A concept written directly on a template parameter
230
(\c {template <Ordered T> class SortedSet}).
231
\endlist
232
233
The \\concept command is typically followed by an \l
234
{inmodule-command} {\\inmodule} command and a \l {brief-command}
235
{\\brief} description. The body of the comment is rendered as the
236
detailed description; \l {sectionOne-command} {\\section1} headings
237
work as they do on any other documentation page.
238
239
\badcode *
240
/\1!
241
\concept Ordered
242
\inmodule Algorithms
243
244
\brief A type that admits a total order.
245
246
The Ordered concept is satisfied by any type that supplies the
247
relational operators \c {<}, \c {<=}, \c {>}, and \c {>=}, and for
248
which those operators induce a strict total order.
249
250
\section1 Definition
251
252
Ordered evaluates to \c true when \c {T} is totally ordered
253
and to \c false otherwise.
254
\1/
255
\endcode
256
257
QDoc generates a reference page for the concept. For the example
258
above, the page is \c {ordered.html}, containing the brief, the
259
detailed description, and a \e {Used by} section listing the
260
documented types and functions included in the generated
261
documentation whose constraints reference \c {Ordered}. Each entry
262
is rendered as a link followed by the \\brief description from the
263
entry's own documentation, in the same shape as the listings on
264
\\group and \\module pages.
265
266
Concept references to undocumented concepts, such as concepts that
267
live in the standard library, are silently ignored. They don't
268
produce a page and don't emit a warning.
269
270
See also \l {group-command} {\\group}, \l {module-command}
271
{\\module}, and \l {inmodule-command} {\\inmodule}.
272
273
\target enum-command
274
\section1 \\enum
275
276
The \\enum command is for documenting a C++ enum type. The
277
argument is the full name of the enum type.
278
279
The enum values are documented in the \\enum comment using the \l
280
{value-command} {\\value} command. If an enum value is not
281
documented with \\value, QDoc emits a warning. These warnings can
282
be avoided using the \l {omitvalue-command} {\\omitvalue} command
283
to tell QDoc that an enum value should not be documented. The enum
284
documentation will be included on the class reference page, header
285
file page, or namespace page where the enum type is defined. For
286
example, consider the enum type \c {Corner} in the Qt namespace:
287
288
\code
289
enum Corner {
290
TopLeftCorner = 0x00000,
291
TopRightCorner = 0x00001,
292
BottomLeftCorner = 0x00002,
293
BottomRightCorner = 0x00003
294
#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
295
,TopLeft = TopLeftCorner,
296
TopRight = TopRightCorner,
297
BottomLeft = BottomLeftCorner,
298
BottomRight = BottomRightCorner
299
#endif
300
};
301
\endcode
302
303
This enum can be documented this way:
304
305
\badcode *
306
/\1!
307
\enum Qt::Corner
308
309
This enum type specifies a corner in a rectangle:
310
311
\value TopLeftCorner
312
The top-left corner of the rectangle.
313
\value TopRightCorner
314
The top-right corner of the rectangle.
315
\value BottomLeftCorner
316
The bottom-left corner of the rectangle.
317
\value BottomRightCorner
318
The bottom-right corner of the rectangle.
319
320
\omitvalue TopLeft
321
\omitvalue TopRight
322
\omitvalue BottomLeft
323
\omitvalue BottomRight
324
Bottom-right (omitted; not documented).
325
\1/
326
\endcode
327
328
Note the inclusion of the namespace qualifier.
329
330
See also \l {value-command} {\\value} and \l {omitvalue-command} {\\omitvalue}.
331
332
\target example-command
333
\section1 \\example
334
335
The \\example command is for documenting an example. The argument
336
is the example's path relative to one of the paths listed in the
337
\l {exampledirs-variable} {exampledirs} variable in the QDoc
338
configuration file.
339
340
The documentation page will be output to \c {modulename-path-to-example}.html.
341
QDoc will add a list of all the example's source and images files at the end
342
of the page, unless \l {noautolist-command}{\\noautolist} command is used or
343
the configuration variable \l {url.examples-variable}{url.examples} is defined
344
for the project.
345
346
For example, if \l {exampledirs-variable} {exampledirs} contains
347
\c $QTDIR/examples/widgets/imageviewer, then
348
349
\badcode *
350
/\1!
351
\example widgets/imageviewer
352
\title ImageViewer Example
353
\subtitle
354
355
The example shows how to combine QLabel and QScrollArea
356
to display an image.
357
358
...
359
\1/
360
\endcode
361
362
\b {See also:} \l {noautolist-command}{\\noautolist},
363
\l {url.examples-variable}{url.examples},
364
\l {meta-command}{\\meta}
365
366
\target externalpage-command
367
\section1 \\externalpage
368
369
The \\externalpage command assigns a title to an external URL.
370
371
\badcode *
372
/\1!
373
\externalpage https://doc.qt.io/
374
\title Qt Documentation Site
375
\1/
376
\endcode
377
378
This allows you to include a link to the external page in your
379
documentation this way:
380
381
\badcode *
382
/\1!
383
At the \l {Qt Documentation Site} you can find the latest
384
documentation for Qt, Qt Creator, the Qt SDK and much more.
385
\1/
386
\endcode
387
388
To achieve the same result without using the \\externalpage
389
command, you would have to hard-code the address into your
390
documentation:
391
392
\badcode *
393
/\1!
394
At the \l {http://doc.qt.io/}{Qt Documentation Site}
395
you can find the latest documentation for Qt, Qt Creator, the Qt SDK
396
and much more.
397
\1/
398
\endcode
399
400
The \\externalpage command makes it easier to maintain the
401
documentation. If the address changes, you only need to change the
402
argument of the \\externalpage command.
403
404
\target fn-command
405
\section1 \\fn (function)
406
407
The \\fn command is for documenting a function. The argument is
408
the function's signature, including its template parameters (if
409
any), return type, const-ness, and list of formal arguments with
410
types. If the named function doesn't exist, QDoc emits a warning.
411
412
The command accepts \c auto as the type of a function, even though
413
the full type can be deduced by QDoc. In certain situations, it may
414
be preferable to use \e auto instead of the actual type of a
415
function. Using \c auto as the return type in the
416
\\fn-command lets the author to do this explicitly, also for types
417
that are defined without the \e auto keyword.
418
419
Since QDoc version 6.0, the \\fn command can be used for documenting
420
class members that are not explicitly declared in the header,
421
but are implicitly generated by the compiler; default constructor
422
and destructor, copy constructor and move-copy constructor,
423
assignment operator, and move-assignment operator.
424
425
When documenting a hidden friend, you can use either the
426
class-qualified syntax or the unqualified free function syntax.
427
For example, for:
428
429
\code
430
class Foo {
431
...
432
friend bool operator==(const Foo&, const Foo&) { ... }
433
...
434
}
435
\endcode
436
437
The command can be written as \c{"\fn Foo::operator==(const
438
Foo&, const Foo&)"} or as the free function \c{"\fn bool
439
operator==(const Foo&, const Foo&)"}. QDoc resolves hidden
440
friends by searching classes referenced in the function's
441
parameter types.
442
443
\note The \\fn command is QDoc's default command: when no
444
topic command can be found in a QDoc comment, QDoc tries to tie
445
the documentation to the following code as if it is the
446
documentation for a function. Hence, it is normally not necessary
447
to include this command when documenting a function, if the
448
function's QDoc comment is written immediately above the function
449
implementation in the \c .cpp file. But it must be present when
450
documenting an inline function in the \c .cpp file that is
451
implemented in the \c .h file.
452
453
\badcode *
454
/\1!
455
\fn bool QToolBar::isAreaAllowed(Qt::ToolBarArea area) const
456
457
Returns \c true if this toolbar is dockable in the given
458
\a area; otherwise returns \c false.
459
\1/
460
\endcode
461
462
\note Running in debug mode (pass the \c {-debug} command line option
463
or set the \c QDOC_DEBUG environment variable before invoking QDoc)
464
can help troubleshoot \\fn commands that QDoc fails to parse. In
465
debug mode, additional diagnostic information is available.
466
467
See also \l {overload-command} {\\overload}.
468
469
\target group-command
470
\section1 \\group
471
472
The \\group command creates a separate page that lists the classes,
473
pages, or other entities belonging to a named group. The argument
474
is the group name.
475
476
A class is included in a group by using the \l {ingroup-command}
477
{\\ingroup} command. Overview pages can also be related to a group
478
using the same command, but the list of overview pages must be
479
requested explicitly using the \l {generatelist-command}
480
{\\generatelist} command (see example below).
481
482
The \\group command is typically followed by a \l {title-command}
483
{\\title} command and a short introduction to the group. The
484
HTML page for the group is written to an \c {.html} file named
485
<lower-case-group-name>.html.
486
487
Each entity in the group is listed as a link (using page title
488
or class name), followed by a decription from the \l {brief-command}
489
{\\brief} command in the entity's documentation.
490
491
\badcode *
492
/\1!
493
\group io
494
\title Input/Output and Networking
495
\1/
496
\endcode
497
498
QDoc generates a group page \c{io.html}.
499
500
Note that overview pages related to the group must be listed
501
explicitly using the \l {generatelist-command} {\\generatelist}
502
command with the \c related argument.
503
504
\badcode *
505
/\1!
506
\group architecture
507
508
\title Architecture
509
510
These documents describe aspects of Qt's architecture
511
and design, including overviews of core Qt features and
512
technologies.
513
514
\generatelist{related}
515
\1/
516
\endcode
517
518
See also \l {ingroup-command} {\\ingroup}, \l {annotatedlist-command}
519
{\\annotatedlist}, \l {generatelist-command} {\\generatelist}, and
520
\l {noautolist-command}{\\noautolist}.
521
522
\target headerfile-command
523
\section1 \\headerfile
524
525
The \\headerfile command is for documenting the global functions,
526
types and macros that are declared in a header file, but not in a
527
namespace. The argument is the name of the header file. The HTML
528
page is written to a \c {.html} file constructed from the header
529
file argument.
530
531
The documentation for a function, type, or macro that is declared
532
in the header file being documented, is included in the header file
533
page using the \l {relates-command} {\\relates} command.
534
535
If the argument doesn't exist as a header file, the \\headerfile
536
command creates a documentation page for the header file anyway.
537
538
\badcode *
539
/\1!
540
\headerfile <QtAlgorithms>
541
542
\title Generic Algorithms
543
544
\brief The <QtAlgorithms> header file provides
545
generic template-based algorithms.
546
547
Qt provides a number of global template functions in \c
548
<QtAlgorithms> that work on containers and perform
549
well-know algorithms.
550
\1/
551
\endcode
552
553
QDoc generates a header file page, \c{qtalgorithms.html}.
554
555
See also \l {inheaderfile-command}{\\inheaderfile}.
556
557
\target macro-command
558
\section1 \\macro
559
560
The \\macro command is for documenting a C++ macro. The argument
561
is the macro in one of three styles: function-like macros like
562
Q_ASSERT(), declaration-style macros like Q_PROPERTY(), and macros
563
without parentheses like Q_OBJECT.
564
565
The \\macro comment must contain a \l {relates-command}
566
{\\relates} command that attaches the macro comment to a class,
567
header file, or namespace. Otherwise, the documentation will be
568
lost.
569
570
\target module-command
571
\section1 \\module
572
573
The \\module creates a page that lists the classes belonging to
574
the module specified by the command's argument. A class included
575
in the module by including the \l {inmodule-command} {\\inmodule}
576
command in the \\class comment.
577
578
The \\module command is typically followed by a \l {title-command}
579
{\\title} and a \l {brief-command} {\\brief} command. Each class
580
is listed as a link to the class reference page followed by the
581
text from the class's \l {brief-command} {\\brief} command. For
582
example:
583
584
\badcode *
585
/\1!
586
\module QtNetwork
587
588
\title Qt Network Module
589
590
\brief Contains classes for writing TCP/IP clients and servers.
591
592
The network module provides classes to make network
593
programming easier and portable. It offers both
594
high-level classes such as QNetworkAccessManager that
595
implements application-level protocols, and
596
lower-level classes such as QTcpSocket, QTcpServer, and
597
QUdpSocket.
598
\1/
599
\endcode
600
601
The \l {noautolist-command} {\\noautolist} command can be used here
602
to omit the automatically generated list of classes at the end.
603
604
See also \l {inmodule-command} {\\inmodule}
605
606
\target namespace-command
607
\section1 \\namespace
608
609
The \\namespace command is for documenting the contents of the C++
610
namespace named as its argument. The reference page QDoc generates
611
for a namespace is similar to the reference page it generates for a
612
C++ class.
613
614
\badcode *
615
/\1!
616
\namespace Qt
617
618
\brief Contains miscellaneous identifiers used throughout the Qt library.
619
\1/
620
\endcode
621
622
Note that in C++, a particular namespace can be used in more
623
than one module, but when C++ elements from different modules
624
are declared in the same namespace, the namespace itself must
625
be documented in one module only. For example, namespace Qt in
626
the example above contains types and functions from both QtCore
627
and QtGui, but it is documented with the \\namespace command
628
only in QtCore.
629
630
\target page-command
631
\section1 \\page
632
633
The \\page command is for creating a stand-alone documentation
634
page.
635
636
The \\page command expects a single argument that represents the
637
name of the file where QDoc should store the page.
638
639
The page title is set using the \l {title-command} {\\title}
640
command.
641
642
\badcode *
643
/\1!
644
\page aboutqt.html
645
646
\title About Qt
647
648
Qt is a C++ toolkit for cross-platform GUI
649
application development. Qt provides single-source
650
portability across Microsoft Windows, macOS, Linux,
651
and all major commercial Unix variants.
652
653
Qt provides application developers with all the
654
functionality needed to build applications with
655
state-of-the-art graphical user interfaces. Qt is fully
656
object-oriented, easily extensible, and allows true
657
component programming.
658
659
...
660
\1/
661
\endcode
662
663
QDoc renders this page in \c {aboutqt.html}.
664
665
\target property-command
666
\section1 \\property
667
668
The \\property command is for documenting a Qt property. The
669
argument is the full property name.
670
671
A property is defined using the Q_PROPERTY() macro. The macro
672
takes as arguments the property's name and its set, reset and get
673
functions.
674
675
\badcode
676
Q_PROPERTY(QString state READ state WRITE setState)
677
\endcode
678
679
The set, reset and get functions don't need to be documented,
680
documenting the property is sufficient. QDoc will generate a list
681
of the access function that will appear in the property
682
documentation which in turn will be located in the documentation
683
of the class that defines the property.
684
685
The \\property command comment typically includes a \l
686
{brief-command} {\\brief} command. For properties the \l
687
{brief-command} {\\brief} command's argument is a sentence
688
fragment that will be included in a one line description of the
689
property. The command follows the same rules for the
690
description as the \l {variable-command} {\\variable} command.
691
692
\badcode *
693
/\1!
694
\property QPushButton::flat
695
\brief Whether the border is disabled.
696
697
This property's default is false.
698
\1/
699
\endcode
700
701
\target qmlattachedproperty-command
702
\section1 \\qmlattachedproperty
703
704
The \\qmlattachedproperty command is for documenting a QML
705
property that will be attached to some QML type. See
706
\l{Attached Properties and Attached Signal Handlers}
707
{Attached Properties}. The argument is the rest of the line.
708
It must start with the property type, followed by the QML
709
type name where the property is declared, the \c{::}
710
qualifier, and finally the property name.
711
712
For example, to document a boolean QML attached property named
713
\c isCurrentItem for the \c ListView type:
714
715
\badcode *
716
/\1!
717
\qmlattachedproperty bool ListView::isCurrentItem
718
719
This attached property is \c true if this delegate is the current
720
item; otherwise false.
721
722
It is attached to each instance of the delegate.
723
724
This property may be used to adjust the appearance of the current
725
item, for example:
726
727
\snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
728
\1/
729
\endcode
730
731
QDoc includes this attached property on the QML reference page for the
732
\l [QML] {ListView} type.
733
734
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedproperty
735
accepts a QML module identifier as part of its argument.
736
737
\target qmlattachedsignal-command
738
\section1 \\qmlattachedsignal
739
740
The \\qmlattachedsignal command is for documenting an attachable
741
\l{Signal and Handler Event System}{signal}. The \\qmlattachedsignal
742
command is used just like the \l{qmlsignal-command} {\\qmlsignal} command.
743
744
The argument is the rest of the line. It should be the name of the
745
QML type where the signal is declared, the \c{::}
746
qualifier, and finally the signal name. For example, a QML
747
attached signal named \c add() in the \c GridView
748
element is documented like this:
749
750
\badcode *
751
/\1!
752
\qmlattachedsignal GridView::add()
753
This attached signal is emitted immediately after an item is added to the view.
754
\1/
755
\endcode
756
757
QDoc includes this documentation on the QML reference page for the
758
\l GridView element.
759
760
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedsignal accepts
761
a QML module identifier as part of its argument.
762
763
\target qmlvaluetype-command
764
\section1 \\qmlvaluetype
765
766
The \\qmlvaluetype command is for documenting a \l [QtQml]
767
{QML Value Types}{value type} for QML. The command takes
768
a type name as its only argument.
769
770
\\qmlvaluetype is functionally identical to the
771
\l {qmltype-command}{\\qmltype} command. The only difference
772
is that the type will be titled (and grouped) as a
773
\e {QML value type}.
774
775
\target qmlclass-command
776
\section1 \\qmlclass
777
778
This command is deprecated. Use \l{qmltype-command} {\\qmltype}
779
instead.
780
781
\target qmlenum-command
782
\section1 \\qmlenum
783
784
The \\qmlenum command is for documenting a QML enumeration. The command
785
takes a single argument: the full name of the enumeration type, including
786
the parent QML type and, optionally, the QML module.
787
788
The enumerators and their descriptions are documented using
789
\qdoccmd {value} commands.
790
791
For example,
792
793
\badcode *
794
/\1!
795
\qmlenum My.Module::Color::Channel
796
\brief Specifies a color channel in the RGB colorspace.
797
798
\value R
799
Red color channel
800
801
\value G
802
Green color channel
803
804
\value B
805
Blue color channel
806
\1/
807
\endcode
808
809
This generates documentation for an enumeration \e Channel, with three
810
enumerators: \e {Color.R}, \e {Color.G}, and \e {Color.B}. By default,
811
the parent QML type name is used as a prefix for the enumerators.
812
813
If the first argument to the qdoccmd{value} command already includes a
814
prefix, it is used as is:
815
816
\badcode
817
\value Channel.R
818
Red color channel
819
\value Channel.G
820
Green color channel
821
\value Channel.B
822
Blue color channel
823
\endcode
824
825
Here, the enumerators are listed as \e {Channel.R}, \e {Channel.G}, and
826
\e {Channel.B}.
827
828
Alternatively, it's possible to replicate the enumerators' documentation
829
from an existing C++ \qdoccmd {enum} topic, by using the
830
\qdoccmd {qmlenumeratorsfrom} command.
831
832
This command was introduced with Qt 6.10.
833
834
See also \qdoccmd {qmlenumeratorsfrom}.
835
836
\target qmlmethod-command
837
\section1 \\qmlmethod
838
839
The \\qmlmethod command is for documenting a QML method. The
840
argument is the complete method signature, and must include
841
a return type and parameter names and types enclosed in
842
parentheses. If a method takes no arguments, use \c{()}.
843
844
\badcode *
845
/\1!
846
\qmlmethod void TextInput::select(int start, int end)
847
848
Causes the text from \a start to \a end to be selected.
849
850
If either start or end is out of range, the selection is not changed.
851
852
After having called this, selectionStart will become the lesser, and
853
selectionEnd the greater (regardless of the order passed to this method).
854
855
\sa selectionStart, selectionEnd
856
\1/
857
\endcode
858
859
QDoc includes this documentation on the type reference page for the
860
\l{QtQuick::TextInput::select()}{TextInput} type.
861
862
\target qmltype-command
863
\section1 \\qmltype
864
865
The \\qmltype command is for documenting a QML type. The command
866
has one argument, which is the name of the QML type.
867
868
If the QML type has an equivalent C++ class, you can specify that class
869
with the \qdoccmd nativetype context command.
870
871
The \l {inqmlmodule-command}{\\inqmlmodule} command documents the
872
QML module the type belongs to. The argument passed to this command
873
must match with a documented \l {qmlmodule-command}{\\qmlmodule}
874
page.
875
876
\badcode *
877
/\1!
878
\qmltype Transform
879
\nativetype QGraphicsTransform
880
\inqmlmodule QtQuick
881
882
\brief Provides a way to build advanced transformations on Items.
883
884
The Transform element is a base type which cannot be
885
instantiated directly.
886
\1/
887
\endcode
888
889
Here, the \e{\\qmltype} comment includes \qdoccmd nativetype
890
to specify that a Transform is the QML counterpart to the
891
C++ class QGraphicsTransform. A \\qmltype comment should
892
always include a \l {since-command} {\\since} command, because all
893
QML types are new. It should also include a \l{brief-command}
894
{\\brief} description. If a QML type is a member of a QML type group,
895
the \\qmltype comment should include one or more \l{ingroup-command}
896
{\\ingroup} commands.
897
898
\note QDoc automatically detects QML singleton types and uncreatable types
899
when the corresponding C++ class uses either the \c{QML_SINGLETON} or
900
\c{QML_UNCREATABLE} macro. For such types, using \qdoccmd {qmltype} is
901
sufficient, as the singleton/uncreatable nature will be detected and
902
documented automatically.
903
904
\target qmlsingletontype-command
905
\section1 \\qmlsingletontype
906
907
The \\qmlsingletontype command is for explicitly documenting a QML singleton type.
908
This command is functionally identical to \l{qmltype-command}{\\qmltype}, but it
909
explicitly marks the type as a singleton regardless of the C++ implementation.
910
911
A QML singleton type ensures only one instance exists in the QML engine.
912
The singleton designation is displayed in the generated documentation with
913
a "(Singleton)" indicator in the title and an explanatory note.
914
915
\badcode *
916
/\1!
917
\qmlsingletontype Settings
918
\inqmlmodule MyApp
919
920
\brief Provides application-wide settings as a singleton.
921
922
The Settings type is a singleton that maintains application
923
configuration. Access it directly without instantiation.
924
\1/
925
\endcode
926
927
For C++ classes that use the \c{QML_SINGLETON} macro, prefer using
928
\qdoccmd {qmltype} instead, as QDoc will automatically detect the singleton
929
nature from the C++ code.
930
931
See also \qdoccmd {qmluncreatabletype}.
932
933
\target qmluncreatabletype-command
934
\section1 \\qmluncreatabletype
935
936
The \\qmluncreatabletype command is for explicitly documenting a type that
937
is registered to the QML type system but cannot be instantiated directly in QML.
938
939
This command is functionally identical to \qdoccmd {qmltype}, but it
940
explicitly marks the type as uncreatable regardless of the C++ implementation.
941
942
The uncreatable designation is displayed in the generated documentation with
943
an "(Uncreatable)" indicator in the title and an explanatory note.
944
945
\code [text] *
946
/\1!
947
\qmluncreatabletype Dialog
948
\inqmlmodule QtQuick.Dialogs
949
950
\brief The base type of native dialogs.
951
\1/
952
\endcode
953
954
For C++ classes that use the \c{QML_UNCREATABLE} macro, prefer using
955
\qdoccmd {qmltype} instead, as QDoc will automatically detect the uncreatable
956
nature from the C++ code.
957
958
The \\qmluncreatabletype command was introduced to QDoc in Qt 6.12.
959
960
See also \qdoccmd {qmlsingletontype}.
961
962
\target qmlproperty-command
963
\section1 \\qmlproperty
964
965
The \\qmlproperty command is for documenting a QML property. The
966
argument is the rest of the line. The argument text should be the
967
property type, followed by the QML type name, the \c{::}
968
qualifier, and finally the property name. If we have a QML
969
property named \c x in QML type \c Translate, and the property
970
has type \c {real}, the \\qmlproperty for it would look like this:
971
972
\badcode *
973
/\1!
974
\qmlproperty real Translate::x
975
976
The translation along the X axis.
977
\1/
978
\endcode
979
980
QDoc includes this QML property on the QML reference page for the
981
\l [QML] {Translate} type.
982
983
The \l{default-command}{\\default} command is used to document the
984
default value of a property:
985
986
\badcode
987
\qmlproperty real AxisHelper::gridOpacity
988
\default 0.5
989
\endcode
990
991
If the QML property exposes a C++ enum, the QML property is defined
992
with type \c{enumeration}:
993
994
\badcode
995
\qmlproperty enumeration ParticleShape3D::ShapeType
996
\endcode
997
998
Properties with enumeration type and those that hold a bit-wise
999
combination of flags can use the \l{value-command}{\\value} command
1000
to document the acceptable values.
1001
1002
\badcode
1003
\qmlproperty enumeration Buffer::textureFilterOperation
1004
Specifies the texture filtering mode...
1005
\value Buffer.Nearest Use nearest-neighbor filtering.
1006
\endcode
1007
1008
QDoc also accepts a fully qualified property name, including the
1009
QML module identifier:
1010
1011
\badcode
1012
\qmlproperty bool QtQuick.Controls::Button::highlighted
1013
\endcode
1014
1015
If specified, the module identifier (above, \c {QtQuick.Controls})
1016
must match with the value passed to the \l {inqmlmodule-command}{\\inqmlmodule}
1017
command in the associated \\qmltype documentation. If the name of
1018
the QML type the property belongs to is unique across all types in
1019
the documentation project, the module identifier can be omitted.
1020
1021
\target qmlsignal-command
1022
\section1 \\qmlsignal
1023
1024
The \\qmlsignal command is for documenting a QML signal.
1025
The argument is the rest of the line. The arguments should be: the QML type
1026
where the signal is declared, the \c{::} qualifier, and finally the signal
1027
name. If we have a QML signal named \c clicked(), the documentation for it
1028
would look like this:
1029
1030
\badcode *
1031
/\1!
1032
\qmlsignal MouseArea::clicked(MouseEvent mouse)
1033
1034
This signal is emitted when there is a click. A click is defined as a
1035
press followed by a release, both inside the MouseArea.
1036
\1/
1037
\endcode
1038
1039
QDoc includes this documentation on the QML reference page for the
1040
\l [QML] {MouseArea} type.
1041
1042
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlsignal
1043
accepts a QML module identifier as part of its argument.
1044
1045
\target qmlmodule-command
1046
\section1 \\qmlmodule
1047
1048
Use the \c{\qmlmodule} command to create a \c QML module page. A QML
1049
module page is a collection of QML types or any related material. The
1050
command takes an optional \c <VERSION> number argument, and is similar
1051
to the \l{group-command}.
1052
1053
A QML type is associated with a module by adding the
1054
\l{inqmlmodule-command}{\\inqmlmodule} command to the comment-block that
1055
documents the type. You can link to any member of a QML module using the
1056
module name and two colons (\c{::}) prefix.
1057
1058
\badcode *
1059
/\1!
1060
A link to the TabWidget of the UI Component is \l {UIComponent::TabWidget}.
1061
\1/
1062
\endcode
1063
1064
QDoc generates a page for the module that lists all the members of the
1065
module.
1066
1067
\badcode *
1068
/\1!
1069
\qmlmodule ClickableComponents
1070
1071
This is a list of the Clickable Components set. A Clickable component
1072
responds to a \c clicked() event.
1073
\1/
1074
\endcode
1075
1076
\target inqmlmodule-command
1077
\section1 \\inqmlmodule
1078
1079
A QML type is marked as being available under a specific QML module
1080
import by inserting the \\inqmlmodule command in a
1081
\l {qmltype-command}{\\qmltype} topic. The command takes the module
1082
(import) name, without a version number, as the only argument.
1083
1084
The QML module name must match with a QML module documented with
1085
the (\l{qmlmodule-command}{\\qmlmodule} command).
1086
1087
\badcode *
1088
/\1!
1089
\qmltype ClickableButton
1090
\inqmlmodule ClickableComponents
1091
1092
A clickable button that responds to the \c click() event.
1093
\1/
1094
\endcode
1095
1096
QDoc outputs a row \e {Import statement: import <qmlmodule>}
1097
in a table at the top of the QML type reference page.
1098
1099
When linking to QML types, the QML module identifier may appear in
1100
the link target. For example:
1101
1102
\badcode
1103
\l {ClickableComponents::}{ClickableButton}
1104
\endcode
1105
1106
Links to the type reference page, with \e ClickableButton as the
1107
link text.
1108
1109
\target instantiates-command
1110
\section1 \\instantiates
1111
1112
The \\instantiates command is deprecated since Qt 6.8.
1113
Use \qdoccmd nativetype instead.
1114
1115
1116
\target nativetype-command
1117
\section1 \\nativetype
1118
1119
The \\nativetype-command must be used in conjunction with the
1120
\qdoccmd qmltype topic command. The command takes a C++ class as its
1121
argument. If QDoc cannot find the C++ class, it issues a warning. This
1122
command was introduced with Qt 6.8.
1123
1124
Use the \\nativetype-command to specify what the type is called in C++.
1125
This ensures that the requisites block generated in the documentation for
1126
the QML type contains an "In C++" entry. The C++ class will have a
1127
corresponding "In QML" entry.
1128
1129
Any one QML type can only have one native type. QDoc issues a warning if
1130
redefinition occurs. However, multiple QML types can have the same C++
1131
class as their native type. The C++ class documentation will contain a list
1132
of all corresponding types in QML.
1133
1134
\badcode *
1135
/\1!
1136
\qmltype Transform
1137
\nativetype QGraphicsTransform
1138
\inqmlmodule QtQuick
1139
1140
\brief Provides a way to build advanced transformations on Items.
1141
1142
The Transform element is a base type which cannot be
1143
instantiated directly.
1144
\1/
1145
\endcode
1146
1147
Here, the \e{\\qmltype} topic includes \e{\\nativetype} to specify that a
1148
Transform is called QGraphicsTransform in C++.
1149
1150
1151
\target typealias-command
1152
\section1 \\typealias
1153
1154
The \\typealias command is similar to \l {typedef-command}{\\typedef},
1155
but specific to documenting a C++ type alias:
1156
1157
\code
1158
class Foo
1159
{
1160
public:
1161
using ptr = void*;
1162
// ...
1163
}
1164
\endcode
1165
1166
This can be documented as
1167
1168
\badcode *
1169
/\1!
1170
\typealias Foo::ptr
1171
\1/
1172
\endcode
1173
1174
The \\typealias command was introduced in QDoc 5.15.
1175
1176
See also \l {typedef-command}{\\typedef}.
1177
1178
\target typedef-command
1179
\section1 \\typedef
1180
1181
The \\typedef command is for documenting a C++ typedef. The
1182
argument is the name of the typedef. The documentation for
1183
the typedef will be included in the reference documentation
1184
for the class, namespace, or header file in which the typedef
1185
is declared. To relate the \\typedef to a class, namespace, or
1186
header file, the \\typedef comment must contain a
1187
\l {relates-command} {\\relates} command.
1188
1189
\badcode *
1190
/\1!
1191
\typedef QObjectList
1192
\relates QObject
1193
1194
Synonym for QList<QObject>.
1195
\1/
1196
\endcode
1197
1198
Other typedefs are located on the reference page for the class
1199
that defines them.
1200
1201
\badcode *
1202
/\1!
1203
\typedef QList::Iterator
1204
1205
Qt-style synonym for QList::iterator.
1206
\1/
1207
\endcode
1208
1209
See also \l {typealias-command}{\\typealias}.
1210
1211
\target variable-command
1212
\section1 \\variable
1213
1214
The \\variable command is for documenting a class member variable
1215
or a constant. The argument is the variable or constant name. The
1216
\\variable command comment includes a \l {brief-command} {\\brief}
1217
command. QDoc generates the documentation based on the text from
1218
\\brief command.
1219
1220
The documentation will be located in the in the associated class,
1221
header file, or namespace documentation.
1222
1223
In case of a member variable:
1224
1225
\badcode *
1226
/\1!
1227
\variable QStyleOption::palette
1228
\brief The palette that should be used when painting
1229
the control
1230
\1/
1231
\endcode
1232
1233
You can also document constants with the \\variable command. For
1234
example, suppose you have the \c Type and \c UserType constants in
1235
the QTreeWidgetItem class:
1236
1237
\code
1238
enum { Type = 0, UserType = 1000 };
1239
\endcode
1240
1241
For these, the \\variable command can be used this way:
1242
1243
\badcode *
1244
/\1!
1245
\variable QTreeWidgetItem::Type
1246
1247
The default type for tree widget items.
1248
1249
\sa UserType, type()
1250
\1/
1251
\endcode
1252
1253
\badcode *
1254
/\1!
1255
\variable QTreeWidgetItem::UserType
1256
1257
The minimum value for custom types. Values below
1258
UserType are reserved by Qt.
1259
1260
\sa Type, type()
1261
\1/
1262
\endcode
1263
1264
*/
qttools
src
qdoc
qdoc
doc
qdoc-manual-topiccmds.qdoc
Generated on
for Qt by
1.16.1