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 As in C++, a \c const or \c volatile qualifier on a parameter
413 passed by value doesn't distinguish one function from another.
414 For example, \c{\fn void Foo::resize(int size)} documents
415 \c{void resize(const int size)}. Qualifiers on what a pointer or
416 reference refers to, such as the \c const in \c{const char *}, must
417 match. The generated documentation shows parameters as declared.
418
419 The command accepts \c auto as the type of a function, even though
420 the full type can be deduced by QDoc. In certain situations, it may
421 be preferable to use \e auto instead of the actual type of a
422 function. Using \c auto as the return type in the
423 \\fn-command lets the author to do this explicitly, also for types
424 that are defined without the \e auto keyword.
425
426 Since QDoc version 6.0, the \\fn command can be used for documenting
427 class members that are not explicitly declared in the header,
428 but are implicitly generated by the compiler; default constructor
429 and destructor, copy constructor and move-copy constructor,
430 assignment operator, and move-assignment operator.
431
432 When documenting a hidden friend, you can use either the
433 class-qualified syntax or the unqualified free function syntax.
434 For example, for:
435
436 \code
437 class Foo {
438 ...
439 friend bool operator==(const Foo&, const Foo&) { ... }
440 ...
441 }
442 \endcode
443
444 The command can be written as \c{"\fn Foo::operator==(const
445 Foo&, const Foo&)"} or as the free function \c{"\fn bool
446 operator==(const Foo&, const Foo&)"}. QDoc resolves hidden
447 friends by searching classes referenced in the function's
448 parameter types.
449
450 When the hidden friend is declared in a class template, and the
451 friend itself is not a function template, the free function
452 syntax takes a leading \c template declaration that names the
453 template parameters of the \e{enclosing class}, not of the
454 friend. For example, for:
455
456 \code
457 template <typename T>
458 class MyPair
459 {
460 public:
461 friend void swap(MyPair<T> &a, MyPair<T> &b)
462 { ... }
463 };
464 \endcode
465
466 write:
467
468 \code
469 \fn template <typename T> void swap(MyPair<T> &a, MyPair<T> &b)
470 \endcode
471
472 The parameters of the leading declaration are matched against
473 the class's template parameters positionally, so the
474 documentation may use different names for them; the same name
475 bound to a different parameter describes a different signature
476 and does not match. The class-qualified syntax is also supported
477 for this case. A friend that is itself a function template is
478 documented with its own template declaration, through the
479 ordinary matching rules. The hidden-friend interpretation is a
480 fallback: if an ordinary match exists for the signature, such as
481 a genuine function template with the same name, QDoc
482 resolves the command to that function instead.
483
484 The fallback supports primary class templates with a single,
485 top-level template declaration containing unconstrained type
486 parameters and explicitly typed non-type parameters. A non-type
487 parameter's type may refer to an earlier type parameter. Names and
488 default arguments do not affect the positional binding.
489
490 Parameter types may use fundamental types, named classes and enums,
491 pointers, references, cv-qualifiers, and class-template specializations.
492 Aliases are compared by their underlying types. Template arguments
493 may be types, references to the enclosing template's non-type
494 parameters, or fixed integral values.
495
496 The fallback does not perform C++ template deduction. It does not
497 support constrained or variadic template parameters, template-template
498 parameters, \c{auto} non-type parameters, nested template contexts,
499 or partial specializations. Dependent expressions other than a
500 non-type parameter reference, dependent member types, \c{decltype},
501 arrays, function pointers, and member pointers are also outside its
502 scope. The enclosing class must appear directly in a function
503 parameter type, possibly behind pointers or references; QDoc does
504 not search inside another template's arguments for hidden friends.
505 These restrictions apply to this fallback, not to ordinary function
506 template matching or the class-qualified syntax.
507
508 If no ordinary function or unique supported hidden friend matches,
509 QDoc reports an unresolved \c{\fn} command. This includes unsupported fallback forms
510 and ambiguous matches.
511
512 \note The \\fn command is QDoc's default command: when no
513 topic command can be found in a QDoc comment, QDoc tries to tie
514 the documentation to the following code as if it is the
515 documentation for a function. Hence, it is normally not necessary
516 to include this command when documenting a function, if the
517 function's QDoc comment is written immediately above the function
518 implementation in the \c .cpp file. But it must be present when
519 documenting an inline function in the \c .cpp file that is
520 implemented in the \c .h file.
521
522 \badcode *
523 /\1!
524 \fn bool QToolBar::isAreaAllowed(Qt::ToolBarArea area) const
525
526 Returns \c true if this toolbar is dockable in the given
527 \a area; otherwise returns \c false.
528 \1/
529 \endcode
530
531 \note Running in debug mode (pass the \c {-debug} command line option
532 or set the \c QDOC_DEBUG environment variable before invoking QDoc)
533 can help troubleshoot \\fn commands that QDoc fails to parse. In
534 debug mode, additional diagnostic information is available.
535
536 See also \l {overload-command} {\\overload}.
537
538 \target group-command
539 \section1 \\group
540
541 The \\group command creates a separate page that lists the classes,
542 pages, or other entities belonging to a named group. The argument
543 is the group name.
544
545 A class is included in a group by using the \l {ingroup-command}
546 {\\ingroup} command. Overview pages can also be related to a group
547 using the same command, but the list of overview pages must be
548 requested explicitly using the \l {generatelist-command}
549 {\\generatelist} command (see example below).
550
551 The \\group command is typically followed by a \l {title-command}
552 {\\title} command and a short introduction to the group. The
553 HTML page for the group is written to an \c {.html} file named
554 <lower-case-group-name>.html.
555
556 Each entity in the group is listed as a link (using page title
557 or class name), followed by a decription from the \l {brief-command}
558 {\\brief} command in the entity's documentation.
559
560 \badcode *
561 /\1!
562 \group io
563 \title Input/Output and Networking
564 \1/
565 \endcode
566
567 QDoc generates a group page \c{io.html}.
568
569 Note that overview pages related to the group must be listed
570 explicitly using the \l {generatelist-command} {\\generatelist}
571 command with the \c related argument.
572
573 \badcode *
574 /\1!
575 \group architecture
576
577 \title Architecture
578
579 These documents describe aspects of Qt's architecture
580 and design, including overviews of core Qt features and
581 technologies.
582
583 \generatelist{related}
584 \1/
585 \endcode
586
587 See also \l {ingroup-command} {\\ingroup}, \l {annotatedlist-command}
588 {\\annotatedlist}, \l {generatelist-command} {\\generatelist}, and
589 \l {noautolist-command}{\\noautolist}.
590
591 \target headerfile-command
592 \section1 \\headerfile
593
594 The \\headerfile command is for documenting the global functions,
595 types and macros that are declared in a header file, but not in a
596 namespace. The argument is the name of the header file. The HTML
597 page is written to a \c {.html} file constructed from the header
598 file argument.
599
600 The documentation for a function, type, or macro that is declared
601 in the header file being documented, is included in the header file
602 page using the \l {relates-command} {\\relates} command.
603
604 If the argument doesn't exist as a header file, the \\headerfile
605 command creates a documentation page for the header file anyway.
606
607 \badcode *
608 /\1!
609 \headerfile <QtAlgorithms>
610
611 \title Generic Algorithms
612
613 \brief The <QtAlgorithms> header file provides
614 generic template-based algorithms.
615
616 Qt provides a number of global template functions in \c
617 <QtAlgorithms> that work on containers and perform
618 well-know algorithms.
619 \1/
620 \endcode
621
622 QDoc generates a header file page, \c{qtalgorithms.html}.
623
624 See also \l {inheaderfile-command}{\\inheaderfile}.
625
626 \target macro-command
627 \section1 \\macro
628
629 The \\macro command is for documenting a C++ macro. The argument
630 is the macro in one of three styles: function-like macros like
631 Q_ASSERT(), declaration-style macros like Q_PROPERTY(), and macros
632 without parentheses like Q_OBJECT.
633
634 The \\macro comment must contain a \l {relates-command}
635 {\\relates} command that attaches the macro comment to a class,
636 header file, or namespace. Otherwise, the documentation will be
637 lost.
638
639 \target module-command
640 \section1 \\module
641
642 The \\module creates a page that lists the classes belonging to
643 the module specified by the command's argument. A class included
644 in the module by including the \l {inmodule-command} {\\inmodule}
645 command in the \\class comment.
646
647 The \\module command is typically followed by a \l {title-command}
648 {\\title} and a \l {brief-command} {\\brief} command. Each class
649 is listed as a link to the class reference page followed by the
650 text from the class's \l {brief-command} {\\brief} command. For
651 example:
652
653 \badcode *
654 /\1!
655 \module QtNetwork
656
657 \title Qt Network Module
658
659 \brief Contains classes for writing TCP/IP clients and servers.
660
661 The network module provides classes to make network
662 programming easier and portable. It offers both
663 high-level classes such as QNetworkAccessManager that
664 implements application-level protocols, and
665 lower-level classes such as QTcpSocket, QTcpServer, and
666 QUdpSocket.
667 \1/
668 \endcode
669
670 The \l {noautolist-command} {\\noautolist} command can be used here
671 to omit the automatically generated list of classes at the end.
672
673 See also \l {inmodule-command} {\\inmodule}
674
675 \target namespace-command
676 \section1 \\namespace
677
678 The \\namespace command is for documenting the contents of the C++
679 namespace named as its argument. The reference page QDoc generates
680 for a namespace is similar to the reference page it generates for a
681 C++ class.
682
683 \badcode *
684 /\1!
685 \namespace Qt
686
687 \brief Contains miscellaneous identifiers used throughout the Qt library.
688 \1/
689 \endcode
690
691 Note that in C++, a particular namespace can be used in more
692 than one module, but when C++ elements from different modules
693 are declared in the same namespace, the namespace itself must
694 be documented in one module only. For example, namespace Qt in
695 the example above contains types and functions from both QtCore
696 and QtGui, but it is documented with the \\namespace command
697 only in QtCore.
698
699 \target page-command
700 \section1 \\page
701
702 The \\page command is for creating a stand-alone documentation
703 page.
704
705 The \\page command expects a single argument that represents the
706 name of the file where QDoc should store the page.
707
708 The page title is set using the \l {title-command} {\\title}
709 command.
710
711 \badcode *
712 /\1!
713 \page aboutqt.html
714
715 \title About Qt
716
717 Qt is a C++ toolkit for cross-platform GUI
718 application development. Qt provides single-source
719 portability across Microsoft Windows, macOS, Linux,
720 and all major commercial Unix variants.
721
722 Qt provides application developers with all the
723 functionality needed to build applications with
724 state-of-the-art graphical user interfaces. Qt is fully
725 object-oriented, easily extensible, and allows true
726 component programming.
727
728 ...
729 \1/
730 \endcode
731
732 QDoc renders this page in \c {aboutqt.html}.
733
734 \target property-command
735 \section1 \\property
736
737 The \\property command is for documenting a Qt property. The
738 argument is the full property name.
739
740 A property is defined using the Q_PROPERTY() macro. The macro
741 takes as arguments the property's name and its set, reset and get
742 functions.
743
744 \badcode
745 Q_PROPERTY(QString state READ state WRITE setState)
746 \endcode
747
748 The set, reset and get functions don't need to be documented,
749 documenting the property is sufficient. QDoc will generate a list
750 of the access function that will appear in the property
751 documentation which in turn will be located in the documentation
752 of the class that defines the property.
753
754 The \\property command comment typically includes a \l
755 {brief-command} {\\brief} command. For properties the \l
756 {brief-command} {\\brief} command's argument is a sentence
757 fragment that will be included in a one line description of the
758 property. The command follows the same rules for the
759 description as the \l {variable-command} {\\variable} command.
760
761 \badcode *
762 /\1!
763 \property QPushButton::flat
764 \brief Whether the border is disabled.
765
766 This property's default is false.
767 \1/
768 \endcode
769
770 \target qmlattachedmethod-command
771 \section1 \\qmlattachedmethod
772
773 The \\qmlattachedmethod command is for documenting a method that is attached
774 to some QML type (\l{Attached Properties and Attached Signal Handlers}
775 {Attached Properties}). The \\qmlattachedmethod command is used just like
776 the \l{qmlmethod-command} {\\qmlmethod} command.
777
778 The argument is the rest of the line, and must be the complete method
779 signature, starting with the return type, followed by the QML type
780 name where the method is declared, the \c{::} qualifier, and finally
781 the method name with its parameter types and names enclosed in
782 parentheses. If a method takes no arguments, use \c{()}.
783
784 For example, to document an attached method named \c show() for the
785 \c ToolTip type:
786
787 \code [text] *
788 /\1!
789 \qmlattachedmethod void QtQuick.Controls::ToolTip::show(string text, int timeout = -1)
790
791 This attached method shows the shared tool tip with \a text for
792 \a timeout milliseconds. You can attach the method to any item.
793 \1/
794 \endcode
795
796 QDoc includes this documentation on the QML reference page for the
797 \l [QML] {ToolTip} type.
798
799 \note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedmethod
800 accepts a QML module identifier as part of its argument.
801
802 \target qmlattachedproperty-command
803 \section1 \\qmlattachedproperty
804
805 The \\qmlattachedproperty command is for documenting a QML
806 property that will be attached to some QML type. See
807 \l{Attached Properties and Attached Signal Handlers}
808 {Attached Properties}. The argument is the rest of the line.
809 It must start with the property type, followed by the QML
810 type name where the property is declared, the \c{::}
811 qualifier, and finally the property name.
812
813 For example, to document a boolean QML attached property named
814 \c isCurrentItem for the \c ListView type:
815
816 \badcode *
817 /\1!
818 \qmlattachedproperty bool ListView::isCurrentItem
819
820 This attached property is \c true if this delegate is the current
821 item; otherwise false.
822
823 It is attached to each instance of the delegate.
824
825 This property may be used to adjust the appearance of the current
826 item, for example:
827
828 \snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
829 \1/
830 \endcode
831
832 QDoc includes this attached property on the QML reference page for the
833 \l [QML] {ListView} type.
834
835 \note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedproperty
836 accepts a QML module identifier as part of its argument.
837
838 \target qmlattachedsignal-command
839 \section1 \\qmlattachedsignal
840
841 The \\qmlattachedsignal command is for documenting an attachable
842 \l{Signal and Handler Event System}{signal}. The \\qmlattachedsignal
843 command is used just like the \l{qmlsignal-command} {\\qmlsignal} command.
844
845 The argument is the rest of the line. It should be the name of the
846 QML type where the signal is declared, the \c{::}
847 qualifier, and finally the signal name. For example, a QML
848 attached signal named \c add() in the \c GridView
849 element is documented like this:
850
851 \badcode *
852 /\1!
853 \qmlattachedsignal GridView::add()
854 This attached signal is emitted immediately after an item is added to the view.
855 \1/
856 \endcode
857
858 QDoc includes this documentation on the QML reference page for the
859 \l GridView element.
860
861 \note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedsignal accepts
862 a QML module identifier as part of its argument.
863
864 \target qmlvaluetype-command
865 \section1 \\qmlvaluetype
866
867 The \\qmlvaluetype command is for documenting a \l [QtQml]
868 {QML Value Types}{value type} for QML. The command takes
869 a type name as its only argument.
870
871 \\qmlvaluetype is functionally identical to the
872 \l {qmltype-command}{\\qmltype} command. The only difference
873 is that the type will be titled (and grouped) as a
874 \e {QML value type}.
875
876 \target qmlclass-command
877 \section1 \\qmlclass
878
879 This command is deprecated. Use \l{qmltype-command} {\\qmltype}
880 instead.
881
882 \target qmlenum-command
883 \section1 \\qmlenum
884
885 The \\qmlenum command is for documenting a QML enumeration. The command
886 takes a single argument: the full name of the enumeration type, including
887 the parent QML type and, optionally, the QML module.
888
889 The enumerators and their descriptions are documented using
890 \qdoccmd {value} commands.
891
892 For example,
893
894 \badcode *
895 /\1!
896 \qmlenum My.Module::Color::Channel
897 \brief Specifies a color channel in the RGB colorspace.
898
899 \value R
900 Red color channel
901
902 \value G
903 Green color channel
904
905 \value B
906 Blue color channel
907 \1/
908 \endcode
909
910 This generates documentation for an enumeration \e Channel, with three
911 enumerators: \e {Color.R}, \e {Color.G}, and \e {Color.B}. By default,
912 the parent QML type name is used as a prefix for the enumerators.
913
914 If the first argument to the qdoccmd{value} command already includes a
915 prefix, it is used as is:
916
917 \badcode
918 \value Channel.R
919 Red color channel
920 \value Channel.G
921 Green color channel
922 \value Channel.B
923 Blue color channel
924 \endcode
925
926 Here, the enumerators are listed as \e {Channel.R}, \e {Channel.G}, and
927 \e {Channel.B}.
928
929 Alternatively, it's possible to replicate the enumerators' documentation
930 from an existing C++ \qdoccmd {enum} topic, by using the
931 \qdoccmd {qmlenumeratorsfrom} command.
932
933 This command was introduced with Qt 6.10.
934
935 See also \qdoccmd {qmlenumeratorsfrom}.
936
937 \target qmlmethod-command
938 \section1 \\qmlmethod
939
940 The \\qmlmethod command is for documenting a QML method. The
941 argument is the complete method signature, and must include
942 a return type and parameter names and types enclosed in
943 parentheses. If a method takes no arguments, use \c{()}.
944
945 \badcode *
946 /\1!
947 \qmlmethod void TextInput::select(int start, int end)
948
949 Causes the text from \a start to \a end to be selected.
950
951 If either start or end is out of range, the selection is not changed.
952
953 After having called this, selectionStart will become the lesser, and
954 selectionEnd the greater (regardless of the order passed to this method).
955
956 \sa selectionStart, selectionEnd
957 \1/
958 \endcode
959
960 QDoc includes this documentation on the type reference page for the
961 \l{QtQuick::TextInput::select()}{TextInput} type.
962
963 \target qmltype-command
964 \section1 \\qmltype
965
966 The \\qmltype command is for documenting a QML type. The command
967 has one argument, which is the name of the QML type.
968
969 If the QML type has an equivalent C++ class, you can specify that class
970 with the \qdoccmd nativetype context command.
971
972 The \l {inqmlmodule-command}{\\inqmlmodule} command documents the
973 QML module the type belongs to. The argument passed to this command
974 must match with a documented \l {qmlmodule-command}{\\qmlmodule}
975 page.
976
977 \badcode *
978 /\1!
979 \qmltype Transform
980 \nativetype QGraphicsTransform
981 \inqmlmodule QtQuick
982
983 \brief Provides a way to build advanced transformations on Items.
984
985 The Transform element is a base type which cannot be
986 instantiated directly.
987 \1/
988 \endcode
989
990 Here, the \e{\\qmltype} comment includes \qdoccmd nativetype
991 to specify that a Transform is the QML counterpart to the
992 C++ class QGraphicsTransform. A \\qmltype comment should
993 always include a \l {since-command} {\\since} command, because all
994 QML types are new. It should also include a \l{brief-command}
995 {\\brief} description. If a QML type is a member of a QML type group,
996 the \\qmltype comment should include one or more \l{ingroup-command}
997 {\\ingroup} commands.
998
999 \note QDoc automatically detects QML singleton types and uncreatable types
1000 when the corresponding C++ class uses either the \c{QML_SINGLETON} or
1001 \c{QML_UNCREATABLE} macro. For such types, using \qdoccmd {qmltype} is
1002 sufficient, as the singleton/uncreatable nature will be detected and
1003 documented automatically.
1004
1005 \target qmlsingletontype-command
1006 \section1 \\qmlsingletontype
1007
1008 The \\qmlsingletontype command is for explicitly documenting a QML singleton type.
1009 This command is functionally identical to \l{qmltype-command}{\\qmltype}, but it
1010 explicitly marks the type as a singleton regardless of the C++ implementation.
1011
1012 A QML singleton type ensures only one instance exists in the QML engine.
1013 The singleton designation is displayed in the generated documentation with
1014 a "(Singleton)" indicator in the title and an explanatory note.
1015
1016 \badcode *
1017 /\1!
1018 \qmlsingletontype Settings
1019 \inqmlmodule MyApp
1020
1021 \brief Provides application-wide settings as a singleton.
1022
1023 The Settings type is a singleton that maintains application
1024 configuration. Access it directly without instantiation.
1025 \1/
1026 \endcode
1027
1028 For C++ classes that use the \c{QML_SINGLETON} macro, prefer using
1029 \qdoccmd {qmltype} instead, as QDoc will automatically detect the singleton
1030 nature from the C++ code.
1031
1032 See also \qdoccmd {qmluncreatabletype}.
1033
1034 \target qmluncreatabletype-command
1035 \section1 \\qmluncreatabletype
1036
1037 The \\qmluncreatabletype command is for explicitly documenting a type that
1038 is registered to the QML type system but cannot be instantiated directly in QML.
1039
1040 This command is functionally identical to \qdoccmd {qmltype}, but it
1041 explicitly marks the type as uncreatable regardless of the C++ implementation.
1042
1043 The uncreatable designation is displayed in the generated documentation with
1044 an "(Uncreatable)" indicator in the title and an explanatory note.
1045
1046 \code [text] *
1047 /\1!
1048 \qmluncreatabletype Dialog
1049 \inqmlmodule QtQuick.Dialogs
1050
1051 \brief The base type of native dialogs.
1052 \1/
1053 \endcode
1054
1055 For C++ classes that use the \c{QML_UNCREATABLE} macro, prefer using
1056 \qdoccmd {qmltype} instead, as QDoc will automatically detect the uncreatable
1057 nature from the C++ code.
1058
1059 The \\qmluncreatabletype command was introduced to QDoc in Qt 6.12.
1060
1061 See also \qdoccmd {qmlsingletontype}.
1062
1063 \target qmlproperty-command
1064 \section1 \\qmlproperty
1065
1066 The \\qmlproperty command is for documenting a QML property. The
1067 argument is the rest of the line. The argument text should be the
1068 property type, followed by the QML type name, the \c{::}
1069 qualifier, and finally the property name. If we have a QML
1070 property named \c x in QML type \c Translate, and the property
1071 has type \c {real}, the \\qmlproperty for it would look like this:
1072
1073 \badcode *
1074 /\1!
1075 \qmlproperty real Translate::x
1076
1077 The translation along the X axis.
1078 \1/
1079 \endcode
1080
1081 QDoc includes this QML property on the QML reference page for the
1082 \l [QML] {Translate} type.
1083
1084 The \l{default-command}{\\default} command is used to document the
1085 default value of a property:
1086
1087 \badcode
1088 \qmlproperty real AxisHelper::gridOpacity
1089 \default 0.5
1090 \endcode
1091
1092 If the QML property exposes a C++ enum, the QML property is defined
1093 with type \c{enumeration}:
1094
1095 \badcode
1096 \qmlproperty enumeration ParticleShape3D::ShapeType
1097 \endcode
1098
1099 Properties with enumeration type and those that hold a bit-wise
1100 combination of flags can use the \l{value-command}{\\value} command
1101 to document the acceptable values.
1102
1103 \badcode
1104 \qmlproperty enumeration Buffer::textureFilterOperation
1105 Specifies the texture filtering mode...
1106 \value Buffer.Nearest Use nearest-neighbor filtering.
1107 \endcode
1108
1109 QDoc also accepts a fully qualified property name, including the
1110 QML module identifier:
1111
1112 \badcode
1113 \qmlproperty bool QtQuick.Controls::Button::highlighted
1114 \endcode
1115
1116 If specified, the module identifier (above, \c {QtQuick.Controls})
1117 must match with the value passed to the \l {inqmlmodule-command}{\\inqmlmodule}
1118 command in the associated \\qmltype documentation. If the name of
1119 the QML type the property belongs to is unique across all types in
1120 the documentation project, the module identifier can be omitted.
1121
1122 \target qmlsignal-command
1123 \section1 \\qmlsignal
1124
1125 The \\qmlsignal command is for documenting a QML signal.
1126 The argument is the rest of the line. The arguments should be: the QML type
1127 where the signal is declared, the \c{::} qualifier, and finally the signal
1128 name. If we have a QML signal named \c clicked(), the documentation for it
1129 would look like this:
1130
1131 \badcode *
1132 /\1!
1133 \qmlsignal MouseArea::clicked(MouseEvent mouse)
1134
1135 This signal is emitted when there is a click. A click is defined as a
1136 press followed by a release, both inside the MouseArea.
1137 \1/
1138 \endcode
1139
1140 QDoc includes this documentation on the QML reference page for the
1141 \l [QML] {MouseArea} type.
1142
1143 \note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlsignal
1144 accepts a QML module identifier as part of its argument.
1145
1146 \target qmlmodule-command
1147 \section1 \\qmlmodule
1148
1149 Use the \c{\qmlmodule} command to create a \c QML module page. A QML
1150 module page is a collection of QML types or any related material. The
1151 command takes an optional \c <VERSION> number argument, and is similar
1152 to the \l{group-command}.
1153
1154 A QML type is associated with a module by adding the
1155 \l{inqmlmodule-command}{\\inqmlmodule} command to the comment-block that
1156 documents the type. You can link to any member of a QML module using the
1157 module name and a dot (\c{.}) prefix.
1158
1159 \badcode *
1160 /\1!
1161 A link to the TabWidget of the UI Component is \l {UIComponent.TabWidget}.
1162 \1/
1163 \endcode
1164
1165 QDoc generates a page for the module that lists all the members of the
1166 module.
1167
1168 \badcode *
1169 /\1!
1170 \qmlmodule ClickableComponents
1171
1172 This is a list of the Clickable Components set. A Clickable component
1173 responds to a \c clicked() event.
1174 \1/
1175 \endcode
1176
1177 \target inqmlmodule-command
1178 \section1 \\inqmlmodule
1179
1180 A QML type is marked as being available under a specific QML module
1181 import by inserting the \\inqmlmodule command in a
1182 \l {qmltype-command}{\\qmltype} topic. The command takes the module
1183 (import) name, without a version number, as the only argument.
1184
1185 The QML module name must match with a QML module documented with
1186 the (\l{qmlmodule-command}{\\qmlmodule} command).
1187
1188 \badcode *
1189 /\1!
1190 \qmltype ClickableButton
1191 \inqmlmodule ClickableComponents
1192
1193 A clickable button that responds to the \c click() event.
1194 \1/
1195 \endcode
1196
1197 QDoc outputs a row \e {Import statement: import <qmlmodule>}
1198 in a table at the top of the QML type reference page.
1199
1200 When linking to QML types, the QML module identifier may appear in
1201 the link target with a prefix of two colons (\c{::}) prefix, as with
1202 C++ code. For example:
1203
1204 \badcode
1205 \l {ClickableComponents::}{ClickableButton}
1206 \endcode
1207
1208 Links to the type reference page, with \e ClickableButton as the
1209 link text.
1210
1211 \target instantiates-command
1212 \section1 \\instantiates
1213
1214 The \\instantiates command is deprecated since Qt 6.8.
1215 Use \qdoccmd nativetype instead.
1216
1217
1218 \target nativetype-command
1219 \section1 \\nativetype
1220
1221 The \\nativetype-command must be used in conjunction with the
1222 \qdoccmd qmltype topic command. The command takes a C++ class as its
1223 argument. If QDoc cannot find the C++ class, it issues a warning. This
1224 command was introduced with Qt 6.8.
1225
1226 Use the \\nativetype-command to specify what the type is called in C++.
1227 This ensures that the requisites block generated in the documentation for
1228 the QML type contains an "In C++" entry. The C++ class will have a
1229 corresponding "In QML" entry.
1230
1231 Any one QML type can only have one native type. QDoc issues a warning if
1232 redefinition occurs. However, multiple QML types can have the same C++
1233 class as their native type. The C++ class documentation will contain a list
1234 of all corresponding types in QML.
1235
1236 \badcode *
1237 /\1!
1238 \qmltype Transform
1239 \nativetype QGraphicsTransform
1240 \inqmlmodule QtQuick
1241
1242 \brief Provides a way to build advanced transformations on Items.
1243
1244 The Transform element is a base type which cannot be
1245 instantiated directly.
1246 \1/
1247 \endcode
1248
1249 Here, the \e{\\qmltype} topic includes \e{\\nativetype} to specify that a
1250 Transform is called QGraphicsTransform in C++.
1251
1252
1253 \target typealias-command
1254 \section1 \\typealias
1255
1256 The \\typealias command is similar to \l {typedef-command}{\\typedef},
1257 but specific to documenting a C++ type alias:
1258
1259 \code
1260 class Foo
1261 {
1262 public:
1263 using ptr = void*;
1264 // ...
1265 }
1266 \endcode
1267
1268 This can be documented as
1269
1270 \badcode *
1271 /\1!
1272 \typealias Foo::ptr
1273 \1/
1274 \endcode
1275
1276 The \\typealias command was introduced in QDoc 5.15.
1277
1278 See also \l {typedef-command}{\\typedef}.
1279
1280 \target typedef-command
1281 \section1 \\typedef
1282
1283 The \\typedef command is for documenting a C++ typedef. The
1284 argument is the name of the typedef. The documentation for
1285 the typedef will be included in the reference documentation
1286 for the class, namespace, or header file in which the typedef
1287 is declared. To relate the \\typedef to a class, namespace, or
1288 header file, the \\typedef comment must contain a
1289 \l {relates-command} {\\relates} command.
1290
1291 \badcode *
1292 /\1!
1293 \typedef QObjectList
1294 \relates QObject
1295
1296 Synonym for QList<QObject>.
1297 \1/
1298 \endcode
1299
1300 Other typedefs are located on the reference page for the class
1301 that defines them.
1302
1303 \badcode *
1304 /\1!
1305 \typedef QList::Iterator
1306
1307 Qt-style synonym for QList::iterator.
1308 \1/
1309 \endcode
1310
1311 See also \l {typealias-command}{\\typealias}.
1312
1313 \target variable-command
1314 \section1 \\variable
1315
1316 The \\variable command is for documenting a class member variable
1317 or a constant. The argument is the variable or constant name. The
1318 \\variable command comment includes a \l {brief-command} {\\brief}
1319 command. QDoc generates the documentation based on the text from
1320 \\brief command.
1321
1322 The documentation will be located in the in the associated class,
1323 header file, or namespace documentation.
1324
1325 In case of a member variable:
1326
1327 \badcode *
1328 /\1!
1329 \variable QStyleOption::palette
1330 \brief The palette that should be used when painting
1331 the control
1332 \1/
1333 \endcode
1334
1335 You can also document constants with the \\variable command. For
1336 example, suppose you have the \c Type and \c UserType constants in
1337 the QTreeWidgetItem class:
1338
1339 \code
1340 enum { Type = 0, UserType = 1000 };
1341 \endcode
1342
1343 For these, the \\variable command can be used this way:
1344
1345 \badcode *
1346 /\1!
1347 \variable QTreeWidgetItem::Type
1348
1349 The default type for tree widget items.
1350
1351 \sa UserType, type()
1352 \1/
1353 \endcode
1354
1355 \badcode *
1356 /\1!
1357 \variable QTreeWidgetItem::UserType
1358
1359 The minimum value for custom types. Values below
1360 UserType are reserved by Qt.
1361
1362 \sa Type, type()
1363 \1/
1364 \endcode
1365
1366*/