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 qmlattachedmethod-command
702
\section1 \\qmlattachedmethod
703
704
The \\qmlattachedmethod command is for documenting a method that is attached
705
to some QML type (\l{Attached Properties and Attached Signal Handlers}
706
{Attached Properties}). The \\qmlattachedmethod command is used just like
707
the \l{qmlmethod-command} {\\qmlmethod} command.
708
709
The argument is the rest of the line, and must be the complete method
710
signature, starting with the return type, followed by the QML type
711
name where the method is declared, the \c{::} qualifier, and finally
712
the method name with its parameter types and names enclosed in
713
parentheses. If a method takes no arguments, use \c{()}.
714
715
For example, to document an attached method named \c show() for the
716
\c ToolTip type:
717
718
\code [text] *
719
/\1!
720
\qmlattachedmethod void QtQuick.Controls::ToolTip::show(string text, int timeout = -1)
721
722
This attached method shows the shared tool tip with \a text for
723
\a timeout milliseconds. You can attach the method to any item.
724
\1/
725
\endcode
726
727
QDoc includes this documentation on the QML reference page for the
728
\l [QML] {ToolTip} type.
729
730
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedmethod
731
accepts a QML module identifier as part of its argument.
732
733
\target qmlattachedproperty-command
734
\section1 \\qmlattachedproperty
735
736
The \\qmlattachedproperty command is for documenting a QML
737
property that will be attached to some QML type. See
738
\l{Attached Properties and Attached Signal Handlers}
739
{Attached Properties}. The argument is the rest of the line.
740
It must start with the property type, followed by the QML
741
type name where the property is declared, the \c{::}
742
qualifier, and finally the property name.
743
744
For example, to document a boolean QML attached property named
745
\c isCurrentItem for the \c ListView type:
746
747
\badcode *
748
/\1!
749
\qmlattachedproperty bool ListView::isCurrentItem
750
751
This attached property is \c true if this delegate is the current
752
item; otherwise false.
753
754
It is attached to each instance of the delegate.
755
756
This property may be used to adjust the appearance of the current
757
item, for example:
758
759
\snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
760
\1/
761
\endcode
762
763
QDoc includes this attached property on the QML reference page for the
764
\l [QML] {ListView} type.
765
766
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedproperty
767
accepts a QML module identifier as part of its argument.
768
769
\target qmlattachedsignal-command
770
\section1 \\qmlattachedsignal
771
772
The \\qmlattachedsignal command is for documenting an attachable
773
\l{Signal and Handler Event System}{signal}. The \\qmlattachedsignal
774
command is used just like the \l{qmlsignal-command} {\\qmlsignal} command.
775
776
The argument is the rest of the line. It should be the name of the
777
QML type where the signal is declared, the \c{::}
778
qualifier, and finally the signal name. For example, a QML
779
attached signal named \c add() in the \c GridView
780
element is documented like this:
781
782
\badcode *
783
/\1!
784
\qmlattachedsignal GridView::add()
785
This attached signal is emitted immediately after an item is added to the view.
786
\1/
787
\endcode
788
789
QDoc includes this documentation on the QML reference page for the
790
\l GridView element.
791
792
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedsignal accepts
793
a QML module identifier as part of its argument.
794
795
\target qmlvaluetype-command
796
\section1 \\qmlvaluetype
797
798
The \\qmlvaluetype command is for documenting a \l [QtQml]
799
{QML Value Types}{value type} for QML. The command takes
800
a type name as its only argument.
801
802
\\qmlvaluetype is functionally identical to the
803
\l {qmltype-command}{\\qmltype} command. The only difference
804
is that the type will be titled (and grouped) as a
805
\e {QML value type}.
806
807
\target qmlclass-command
808
\section1 \\qmlclass
809
810
This command is deprecated. Use \l{qmltype-command} {\\qmltype}
811
instead.
812
813
\target qmlenum-command
814
\section1 \\qmlenum
815
816
The \\qmlenum command is for documenting a QML enumeration. The command
817
takes a single argument: the full name of the enumeration type, including
818
the parent QML type and, optionally, the QML module.
819
820
The enumerators and their descriptions are documented using
821
\qdoccmd {value} commands.
822
823
For example,
824
825
\badcode *
826
/\1!
827
\qmlenum My.Module::Color::Channel
828
\brief Specifies a color channel in the RGB colorspace.
829
830
\value R
831
Red color channel
832
833
\value G
834
Green color channel
835
836
\value B
837
Blue color channel
838
\1/
839
\endcode
840
841
This generates documentation for an enumeration \e Channel, with three
842
enumerators: \e {Color.R}, \e {Color.G}, and \e {Color.B}. By default,
843
the parent QML type name is used as a prefix for the enumerators.
844
845
If the first argument to the qdoccmd{value} command already includes a
846
prefix, it is used as is:
847
848
\badcode
849
\value Channel.R
850
Red color channel
851
\value Channel.G
852
Green color channel
853
\value Channel.B
854
Blue color channel
855
\endcode
856
857
Here, the enumerators are listed as \e {Channel.R}, \e {Channel.G}, and
858
\e {Channel.B}.
859
860
Alternatively, it's possible to replicate the enumerators' documentation
861
from an existing C++ \qdoccmd {enum} topic, by using the
862
\qdoccmd {qmlenumeratorsfrom} command.
863
864
This command was introduced with Qt 6.10.
865
866
See also \qdoccmd {qmlenumeratorsfrom}.
867
868
\target qmlmethod-command
869
\section1 \\qmlmethod
870
871
The \\qmlmethod command is for documenting a QML method. The
872
argument is the complete method signature, and must include
873
a return type and parameter names and types enclosed in
874
parentheses. If a method takes no arguments, use \c{()}.
875
876
\badcode *
877
/\1!
878
\qmlmethod void TextInput::select(int start, int end)
879
880
Causes the text from \a start to \a end to be selected.
881
882
If either start or end is out of range, the selection is not changed.
883
884
After having called this, selectionStart will become the lesser, and
885
selectionEnd the greater (regardless of the order passed to this method).
886
887
\sa selectionStart, selectionEnd
888
\1/
889
\endcode
890
891
QDoc includes this documentation on the type reference page for the
892
\l{QtQuick::TextInput::select()}{TextInput} type.
893
894
\target qmltype-command
895
\section1 \\qmltype
896
897
The \\qmltype command is for documenting a QML type. The command
898
has one argument, which is the name of the QML type.
899
900
If the QML type has an equivalent C++ class, you can specify that class
901
with the \qdoccmd nativetype context command.
902
903
The \l {inqmlmodule-command}{\\inqmlmodule} command documents the
904
QML module the type belongs to. The argument passed to this command
905
must match with a documented \l {qmlmodule-command}{\\qmlmodule}
906
page.
907
908
\badcode *
909
/\1!
910
\qmltype Transform
911
\nativetype QGraphicsTransform
912
\inqmlmodule QtQuick
913
914
\brief Provides a way to build advanced transformations on Items.
915
916
The Transform element is a base type which cannot be
917
instantiated directly.
918
\1/
919
\endcode
920
921
Here, the \e{\\qmltype} comment includes \qdoccmd nativetype
922
to specify that a Transform is the QML counterpart to the
923
C++ class QGraphicsTransform. A \\qmltype comment should
924
always include a \l {since-command} {\\since} command, because all
925
QML types are new. It should also include a \l{brief-command}
926
{\\brief} description. If a QML type is a member of a QML type group,
927
the \\qmltype comment should include one or more \l{ingroup-command}
928
{\\ingroup} commands.
929
930
\note QDoc automatically detects QML singleton types and uncreatable types
931
when the corresponding C++ class uses either the \c{QML_SINGLETON} or
932
\c{QML_UNCREATABLE} macro. For such types, using \qdoccmd {qmltype} is
933
sufficient, as the singleton/uncreatable nature will be detected and
934
documented automatically.
935
936
\target qmlsingletontype-command
937
\section1 \\qmlsingletontype
938
939
The \\qmlsingletontype command is for explicitly documenting a QML singleton type.
940
This command is functionally identical to \l{qmltype-command}{\\qmltype}, but it
941
explicitly marks the type as a singleton regardless of the C++ implementation.
942
943
A QML singleton type ensures only one instance exists in the QML engine.
944
The singleton designation is displayed in the generated documentation with
945
a "(Singleton)" indicator in the title and an explanatory note.
946
947
\badcode *
948
/\1!
949
\qmlsingletontype Settings
950
\inqmlmodule MyApp
951
952
\brief Provides application-wide settings as a singleton.
953
954
The Settings type is a singleton that maintains application
955
configuration. Access it directly without instantiation.
956
\1/
957
\endcode
958
959
For C++ classes that use the \c{QML_SINGLETON} macro, prefer using
960
\qdoccmd {qmltype} instead, as QDoc will automatically detect the singleton
961
nature from the C++ code.
962
963
See also \qdoccmd {qmluncreatabletype}.
964
965
\target qmluncreatabletype-command
966
\section1 \\qmluncreatabletype
967
968
The \\qmluncreatabletype command is for explicitly documenting a type that
969
is registered to the QML type system but cannot be instantiated directly in QML.
970
971
This command is functionally identical to \qdoccmd {qmltype}, but it
972
explicitly marks the type as uncreatable regardless of the C++ implementation.
973
974
The uncreatable designation is displayed in the generated documentation with
975
an "(Uncreatable)" indicator in the title and an explanatory note.
976
977
\code [text] *
978
/\1!
979
\qmluncreatabletype Dialog
980
\inqmlmodule QtQuick.Dialogs
981
982
\brief The base type of native dialogs.
983
\1/
984
\endcode
985
986
For C++ classes that use the \c{QML_UNCREATABLE} macro, prefer using
987
\qdoccmd {qmltype} instead, as QDoc will automatically detect the uncreatable
988
nature from the C++ code.
989
990
The \\qmluncreatabletype command was introduced to QDoc in Qt 6.12.
991
992
See also \qdoccmd {qmlsingletontype}.
993
994
\target qmlproperty-command
995
\section1 \\qmlproperty
996
997
The \\qmlproperty command is for documenting a QML property. The
998
argument is the rest of the line. The argument text should be the
999
property type, followed by the QML type name, the \c{::}
1000
qualifier, and finally the property name. If we have a QML
1001
property named \c x in QML type \c Translate, and the property
1002
has type \c {real}, the \\qmlproperty for it would look like this:
1003
1004
\badcode *
1005
/\1!
1006
\qmlproperty real Translate::x
1007
1008
The translation along the X axis.
1009
\1/
1010
\endcode
1011
1012
QDoc includes this QML property on the QML reference page for the
1013
\l [QML] {Translate} type.
1014
1015
The \l{default-command}{\\default} command is used to document the
1016
default value of a property:
1017
1018
\badcode
1019
\qmlproperty real AxisHelper::gridOpacity
1020
\default 0.5
1021
\endcode
1022
1023
If the QML property exposes a C++ enum, the QML property is defined
1024
with type \c{enumeration}:
1025
1026
\badcode
1027
\qmlproperty enumeration ParticleShape3D::ShapeType
1028
\endcode
1029
1030
Properties with enumeration type and those that hold a bit-wise
1031
combination of flags can use the \l{value-command}{\\value} command
1032
to document the acceptable values.
1033
1034
\badcode
1035
\qmlproperty enumeration Buffer::textureFilterOperation
1036
Specifies the texture filtering mode...
1037
\value Buffer.Nearest Use nearest-neighbor filtering.
1038
\endcode
1039
1040
QDoc also accepts a fully qualified property name, including the
1041
QML module identifier:
1042
1043
\badcode
1044
\qmlproperty bool QtQuick.Controls::Button::highlighted
1045
\endcode
1046
1047
If specified, the module identifier (above, \c {QtQuick.Controls})
1048
must match with the value passed to the \l {inqmlmodule-command}{\\inqmlmodule}
1049
command in the associated \\qmltype documentation. If the name of
1050
the QML type the property belongs to is unique across all types in
1051
the documentation project, the module identifier can be omitted.
1052
1053
\target qmlsignal-command
1054
\section1 \\qmlsignal
1055
1056
The \\qmlsignal command is for documenting a QML signal.
1057
The argument is the rest of the line. The arguments should be: the QML type
1058
where the signal is declared, the \c{::} qualifier, and finally the signal
1059
name. If we have a QML signal named \c clicked(), the documentation for it
1060
would look like this:
1061
1062
\badcode *
1063
/\1!
1064
\qmlsignal MouseArea::clicked(MouseEvent mouse)
1065
1066
This signal is emitted when there is a click. A click is defined as a
1067
press followed by a release, both inside the MouseArea.
1068
\1/
1069
\endcode
1070
1071
QDoc includes this documentation on the QML reference page for the
1072
\l [QML] {MouseArea} type.
1073
1074
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlsignal
1075
accepts a QML module identifier as part of its argument.
1076
1077
\target qmlmodule-command
1078
\section1 \\qmlmodule
1079
1080
Use the \c{\qmlmodule} command to create a \c QML module page. A QML
1081
module page is a collection of QML types or any related material. The
1082
command takes an optional \c <VERSION> number argument, and is similar
1083
to the \l{group-command}.
1084
1085
A QML type is associated with a module by adding the
1086
\l{inqmlmodule-command}{\\inqmlmodule} command to the comment-block that
1087
documents the type. You can link to any member of a QML module using the
1088
module name and a dot (\c{.}) prefix.
1089
1090
\badcode *
1091
/\1!
1092
A link to the TabWidget of the UI Component is \l {UIComponent.TabWidget}.
1093
\1/
1094
\endcode
1095
1096
QDoc generates a page for the module that lists all the members of the
1097
module.
1098
1099
\badcode *
1100
/\1!
1101
\qmlmodule ClickableComponents
1102
1103
This is a list of the Clickable Components set. A Clickable component
1104
responds to a \c clicked() event.
1105
\1/
1106
\endcode
1107
1108
\target inqmlmodule-command
1109
\section1 \\inqmlmodule
1110
1111
A QML type is marked as being available under a specific QML module
1112
import by inserting the \\inqmlmodule command in a
1113
\l {qmltype-command}{\\qmltype} topic. The command takes the module
1114
(import) name, without a version number, as the only argument.
1115
1116
The QML module name must match with a QML module documented with
1117
the (\l{qmlmodule-command}{\\qmlmodule} command).
1118
1119
\badcode *
1120
/\1!
1121
\qmltype ClickableButton
1122
\inqmlmodule ClickableComponents
1123
1124
A clickable button that responds to the \c click() event.
1125
\1/
1126
\endcode
1127
1128
QDoc outputs a row \e {Import statement: import <qmlmodule>}
1129
in a table at the top of the QML type reference page.
1130
1131
When linking to QML types, the QML module identifier may appear in
1132
the link target with a prefix of two colons (\c{::}) prefix, as with
1133
C++ code. For example:
1134
1135
\badcode
1136
\l {ClickableComponents::}{ClickableButton}
1137
\endcode
1138
1139
Links to the type reference page, with \e ClickableButton as the
1140
link text.
1141
1142
\target instantiates-command
1143
\section1 \\instantiates
1144
1145
The \\instantiates command is deprecated since Qt 6.8.
1146
Use \qdoccmd nativetype instead.
1147
1148
1149
\target nativetype-command
1150
\section1 \\nativetype
1151
1152
The \\nativetype-command must be used in conjunction with the
1153
\qdoccmd qmltype topic command. The command takes a C++ class as its
1154
argument. If QDoc cannot find the C++ class, it issues a warning. This
1155
command was introduced with Qt 6.8.
1156
1157
Use the \\nativetype-command to specify what the type is called in C++.
1158
This ensures that the requisites block generated in the documentation for
1159
the QML type contains an "In C++" entry. The C++ class will have a
1160
corresponding "In QML" entry.
1161
1162
Any one QML type can only have one native type. QDoc issues a warning if
1163
redefinition occurs. However, multiple QML types can have the same C++
1164
class as their native type. The C++ class documentation will contain a list
1165
of all corresponding types in QML.
1166
1167
\badcode *
1168
/\1!
1169
\qmltype Transform
1170
\nativetype QGraphicsTransform
1171
\inqmlmodule QtQuick
1172
1173
\brief Provides a way to build advanced transformations on Items.
1174
1175
The Transform element is a base type which cannot be
1176
instantiated directly.
1177
\1/
1178
\endcode
1179
1180
Here, the \e{\\qmltype} topic includes \e{\\nativetype} to specify that a
1181
Transform is called QGraphicsTransform in C++.
1182
1183
1184
\target typealias-command
1185
\section1 \\typealias
1186
1187
The \\typealias command is similar to \l {typedef-command}{\\typedef},
1188
but specific to documenting a C++ type alias:
1189
1190
\code
1191
class Foo
1192
{
1193
public:
1194
using ptr = void*;
1195
// ...
1196
}
1197
\endcode
1198
1199
This can be documented as
1200
1201
\badcode *
1202
/\1!
1203
\typealias Foo::ptr
1204
\1/
1205
\endcode
1206
1207
The \\typealias command was introduced in QDoc 5.15.
1208
1209
See also \l {typedef-command}{\\typedef}.
1210
1211
\target typedef-command
1212
\section1 \\typedef
1213
1214
The \\typedef command is for documenting a C++ typedef. The
1215
argument is the name of the typedef. The documentation for
1216
the typedef will be included in the reference documentation
1217
for the class, namespace, or header file in which the typedef
1218
is declared. To relate the \\typedef to a class, namespace, or
1219
header file, the \\typedef comment must contain a
1220
\l {relates-command} {\\relates} command.
1221
1222
\badcode *
1223
/\1!
1224
\typedef QObjectList
1225
\relates QObject
1226
1227
Synonym for QList<QObject>.
1228
\1/
1229
\endcode
1230
1231
Other typedefs are located on the reference page for the class
1232
that defines them.
1233
1234
\badcode *
1235
/\1!
1236
\typedef QList::Iterator
1237
1238
Qt-style synonym for QList::iterator.
1239
\1/
1240
\endcode
1241
1242
See also \l {typealias-command}{\\typealias}.
1243
1244
\target variable-command
1245
\section1 \\variable
1246
1247
The \\variable command is for documenting a class member variable
1248
or a constant. The argument is the variable or constant name. The
1249
\\variable command comment includes a \l {brief-command} {\\brief}
1250
command. QDoc generates the documentation based on the text from
1251
\\brief command.
1252
1253
The documentation will be located in the in the associated class,
1254
header file, or namespace documentation.
1255
1256
In case of a member variable:
1257
1258
\badcode *
1259
/\1!
1260
\variable QStyleOption::palette
1261
\brief The palette that should be used when painting
1262
the control
1263
\1/
1264
\endcode
1265
1266
You can also document constants with the \\variable command. For
1267
example, suppose you have the \c Type and \c UserType constants in
1268
the QTreeWidgetItem class:
1269
1270
\code
1271
enum { Type = 0, UserType = 1000 };
1272
\endcode
1273
1274
For these, the \\variable command can be used this way:
1275
1276
\badcode *
1277
/\1!
1278
\variable QTreeWidgetItem::Type
1279
1280
The default type for tree widget items.
1281
1282
\sa UserType, type()
1283
\1/
1284
\endcode
1285
1286
\badcode *
1287
/\1!
1288
\variable QTreeWidgetItem::UserType
1289
1290
The minimum value for custom types. Values below
1291
UserType are reserved by Qt.
1292
1293
\sa Type, type()
1294
\1/
1295
\endcode
1296
1297
*/
qttools
src
qdoc
qdoc
doc
qdoc-manual-topiccmds.qdoc
Generated on
for Qt by
1.16.1