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 enum-command
205
\section1 \\enum
206
207
The \\enum command is for documenting a C++ enum type. The
208
argument is the full name of the enum type.
209
210
The enum values are documented in the \\enum comment using the \l
211
{value-command} {\\value} command. If an enum value is not
212
documented with \\value, QDoc emits a warning. These warnings can
213
be avoided using the \l {omitvalue-command} {\\omitvalue} command
214
to tell QDoc that an enum value should not be documented. The enum
215
documentation will be included on the class reference page, header
216
file page, or namespace page where the enum type is defined. For
217
example, consider the enum type \c {Corner} in the Qt namespace:
218
219
\code
220
enum Corner {
221
TopLeftCorner = 0x00000,
222
TopRightCorner = 0x00001,
223
BottomLeftCorner = 0x00002,
224
BottomRightCorner = 0x00003
225
#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
226
,TopLeft = TopLeftCorner,
227
TopRight = TopRightCorner,
228
BottomLeft = BottomLeftCorner,
229
BottomRight = BottomRightCorner
230
#endif
231
};
232
\endcode
233
234
This enum can be documented this way:
235
236
\badcode *
237
/\1!
238
\enum Qt::Corner
239
240
This enum type specifies a corner in a rectangle:
241
242
\value TopLeftCorner
243
The top-left corner of the rectangle.
244
\value TopRightCorner
245
The top-right corner of the rectangle.
246
\value BottomLeftCorner
247
The bottom-left corner of the rectangle.
248
\value BottomRightCorner
249
The bottom-right corner of the rectangle.
250
251
\omitvalue TopLeft
252
\omitvalue TopRight
253
\omitvalue BottomLeft
254
\omitvalue BottomRight
255
Bottom-right (omitted; not documented).
256
\1/
257
\endcode
258
259
Note the inclusion of the namespace qualifier.
260
261
See also \l {value-command} {\\value} and \l {omitvalue-command} {\\omitvalue}.
262
263
\target example-command
264
\section1 \\example
265
266
The \\example command is for documenting an example. The argument
267
is the example's path relative to one of the paths listed in the
268
\l {exampledirs-variable} {exampledirs} variable in the QDoc
269
configuration file.
270
271
The documentation page will be output to \c {modulename-path-to-example}.html.
272
QDoc will add a list of all the example's source and images files at the end
273
of the page, unless \l {noautolist-command}{\\noautolist} command is used or
274
the configuration variable \l {url.examples-variable}{url.examples} is defined
275
for the project.
276
277
For example, if \l {exampledirs-variable} {exampledirs} contains
278
\c $QTDIR/examples/widgets/imageviewer, then
279
280
\badcode *
281
/\1!
282
\example widgets/imageviewer
283
\title ImageViewer Example
284
\subtitle
285
286
The example shows how to combine QLabel and QScrollArea
287
to display an image.
288
289
...
290
\1/
291
\endcode
292
293
\b {See also:} \l {noautolist-command}{\\noautolist},
294
\l {url.examples-variable}{url.examples},
295
\l {meta-command}{\\meta}
296
297
\target externalpage-command
298
\section1 \\externalpage
299
300
The \\externalpage command assigns a title to an external URL.
301
302
\badcode *
303
/\1!
304
\externalpage http://doc.qt.io/
305
\title Qt Documentation Site
306
\1/
307
\endcode
308
309
This allows you to include a link to the external page in your
310
documentation this way:
311
312
\badcode *
313
/\1!
314
At the \l {Qt Documentation Site} you can find the latest
315
documentation for Qt, Qt Creator, the Qt SDK and much more.
316
\1/
317
\endcode
318
319
To achieve the same result without using the \\externalpage
320
command, you would have to hard-code the address into your
321
documentation:
322
323
\badcode *
324
/\1!
325
At the \l {http://doc.qt.io/}{Qt Documentation Site}
326
you can find the latest documentation for Qt, Qt Creator, the Qt SDK
327
and much more.
328
\1/
329
\endcode
330
331
The \\externalpage command makes it easier to maintain the
332
documentation. If the address changes, you only need to change the
333
argument of the \\externalpage command.
334
335
\target fn-command
336
\section1 \\fn (function)
337
338
The \\fn command is for documenting a function. The argument is
339
the function's signature, including its template parameters (if
340
any), return type, const-ness, and list of formal arguments with
341
types. If the named function doesn't exist, QDoc emits a warning.
342
343
The command accepts \c auto as the type of a function, even though
344
the full type can be deduced by QDoc. In certain situations, it may
345
be preferable to use \e auto instead of the actual type of a
346
function. Using \c auto as the return type in the
347
\\fn-command lets the author to do this explicitly, also for types
348
that are defined without the \e auto keyword.
349
350
Since QDoc version 6.0, the \\fn command can be used for documenting
351
class members that are not explicitly declared in the header,
352
but are implicitly generated by the compiler; default constructor
353
and destructor, copy constructor and move-copy constructor,
354
assignment operator, and move-assignment operator.
355
356
When documenting a hidden friend, you can use either the
357
class-qualified syntax or the unqualified free function syntax.
358
For example, for:
359
360
\code
361
class Foo {
362
...
363
friend bool operator==(const Foo&, const Foo&) { ... }
364
...
365
}
366
\endcode
367
368
The command can be written as \c{"\fn Foo::operator==(const
369
Foo&, const Foo&)"} or as the free function \c{"\fn bool
370
operator==(const Foo&, const Foo&)"}. QDoc resolves hidden
371
friends by searching classes referenced in the function's
372
parameter types.
373
374
\note The \\fn command is QDoc's default command: when no
375
topic command can be found in a QDoc comment, QDoc tries to tie
376
the documentation to the following code as if it is the
377
documentation for a function. Hence, it is normally not necessary
378
to include this command when documenting a function, if the
379
function's QDoc comment is written immediately above the function
380
implementation in the \c .cpp file. But it must be present when
381
documenting an inline function in the \c .cpp file that is
382
implemented in the \c .h file.
383
384
\badcode *
385
/\1!
386
\fn bool QToolBar::isAreaAllowed(Qt::ToolBarArea area) const
387
388
Returns \c true if this toolbar is dockable in the given
389
\a area; otherwise returns \c false.
390
\1/
391
\endcode
392
393
\note Running in debug mode (pass the \c {-debug} command line option
394
or set the \c QDOC_DEBUG environment variable before invoking QDoc)
395
can help troubleshoot \\fn commands that QDoc fails to parse. In
396
debug mode, additional diagnostic information is available.
397
398
See also \l {overload-command} {\\overload}.
399
400
\target group-command
401
\section1 \\group
402
403
The \\group command creates a separate page that lists the classes,
404
pages, or other entities belonging to a named group. The argument
405
is the group name.
406
407
A class is included in a group by using the \l {ingroup-command}
408
{\\ingroup} command. Overview pages can also be related to a group
409
using the same command, but the list of overview pages must be
410
requested explicitly using the \l {generatelist-command}
411
{\\generatelist} command (see example below).
412
413
The \\group command is typically followed by a \l {title-command}
414
{\\title} command and a short introduction to the group. The
415
HTML page for the group is written to an \c {.html} file named
416
<lower-case-group-name>.html.
417
418
Each entity in the group is listed as a link (using page title
419
or class name), followed by a decription from the \l {brief-command}
420
{\\brief} command in the entity's documentation.
421
422
\badcode *
423
/\1!
424
\group io
425
\title Input/Output and Networking
426
\1/
427
\endcode
428
429
QDoc generates a group page \c{io.html}.
430
431
Note that overview pages related to the group must be listed
432
explicitly using the \l {generatelist-command} {\\generatelist}
433
command with the \c related argument.
434
435
\badcode *
436
/\1!
437
\group architecture
438
439
\title Architecture
440
441
These documents describe aspects of Qt's architecture
442
and design, including overviews of core Qt features and
443
technologies.
444
445
\generatelist{related}
446
\1/
447
\endcode
448
449
See also \l {ingroup-command} {\\ingroup}, \l {annotatedlist-command}
450
{\\annotatedlist}, \l {generatelist-command} {\\generatelist}, and
451
\l {noautolist-command}{\\noautolist}.
452
453
\target headerfile-command
454
\section1 \\headerfile
455
456
The \\headerfile command is for documenting the global functions,
457
types and macros that are declared in a header file, but not in a
458
namespace. The argument is the name of the header file. The HTML
459
page is written to a \c {.html} file constructed from the header
460
file argument.
461
462
The documentation for a function, type, or macro that is declared
463
in the header file being documented, is included in the header file
464
page using the \l {relates-command} {\\relates} command.
465
466
If the argument doesn't exist as a header file, the \\headerfile
467
command creates a documentation page for the header file anyway.
468
469
\badcode *
470
/\1!
471
\headerfile <QtAlgorithms>
472
473
\title Generic Algorithms
474
475
\brief The <QtAlgorithms> header file provides
476
generic template-based algorithms.
477
478
Qt provides a number of global template functions in \c
479
<QtAlgorithms> that work on containers and perform
480
well-know algorithms.
481
\1/
482
\endcode
483
484
QDoc generates a header file page, \c{qtalgorithms.html}.
485
486
See also \l {inheaderfile-command}{\\inheaderfile}.
487
488
\target macro-command
489
\section1 \\macro
490
491
The \\macro command is for documenting a C++ macro. The argument
492
is the macro in one of three styles: function-like macros like
493
Q_ASSERT(), declaration-style macros like Q_PROPERTY(), and macros
494
without parentheses like Q_OBJECT.
495
496
The \\macro comment must contain a \l {relates-command}
497
{\\relates} command that attaches the macro comment to a class,
498
header file, or namespace. Otherwise, the documentation will be
499
lost.
500
501
\target module-command
502
\section1 \\module
503
504
The \\module creates a page that lists the classes belonging to
505
the module specified by the command's argument. A class included
506
in the module by including the \l {inmodule-command} {\\inmodule}
507
command in the \\class comment.
508
509
The \\module command is typically followed by a \l {title-command}
510
{\\title} and a \l {brief-command} {\\brief} command. Each class
511
is listed as a link to the class reference page followed by the
512
text from the class's \l {brief-command} {\\brief} command. For
513
example:
514
515
\badcode *
516
/\1!
517
\module QtNetwork
518
519
\title Qt Network Module
520
521
\brief Contains classes for writing TCP/IP clients and servers.
522
523
The network module provides classes to make network
524
programming easier and portable. It offers both
525
high-level classes such as QNetworkAccessManager that
526
implements application-level protocols, and
527
lower-level classes such as QTcpSocket, QTcpServer, and
528
QUdpSocket.
529
\1/
530
\endcode
531
532
The \l {noautolist-command} {\\noautolist} command can be used here
533
to omit the automatically generated list of classes at the end.
534
535
See also \l {inmodule-command} {\\inmodule}
536
537
\target namespace-command
538
\section1 \\namespace
539
540
The \\namespace command is for documenting the contents of the C++
541
namespace named as its argument. The reference page QDoc generates
542
for a namespace is similar to the reference page it generates for a
543
C++ class.
544
545
\badcode *
546
/\1!
547
\namespace Qt
548
549
\brief Contains miscellaneous identifiers used throughout the Qt library.
550
\1/
551
\endcode
552
553
Note that in C++, a particular namespace can be used in more
554
than one module, but when C++ elements from different modules
555
are declared in the same namespace, the namespace itself must
556
be documented in one module only. For example, namespace Qt in
557
the example above contains types and functions from both QtCore
558
and QtGui, but it is documented with the \\namespace command
559
only in QtCore.
560
561
\target page-command
562
\section1 \\page
563
564
The \\page command is for creating a stand-alone documentation
565
page.
566
567
The \\page command expects a single argument that represents the
568
name of the file where QDoc should store the page.
569
570
The page title is set using the \l {title-command} {\\title}
571
command.
572
573
\badcode *
574
/\1!
575
\page aboutqt.html
576
577
\title About Qt
578
579
Qt is a C++ toolkit for cross-platform GUI
580
application development. Qt provides single-source
581
portability across Microsoft Windows, macOS, Linux,
582
and all major commercial Unix variants.
583
584
Qt provides application developers with all the
585
functionality needed to build applications with
586
state-of-the-art graphical user interfaces. Qt is fully
587
object-oriented, easily extensible, and allows true
588
component programming.
589
590
...
591
\1/
592
\endcode
593
594
QDoc renders this page in \c {aboutqt.html}.
595
596
\target property-command
597
\section1 \\property
598
599
The \\property command is for documenting a Qt property. The
600
argument is the full property name.
601
602
A property is defined using the Q_PROPERTY() macro. The macro
603
takes as arguments the property's name and its set, reset and get
604
functions.
605
606
\badcode
607
Q_PROPERTY(QString state READ state WRITE setState)
608
\endcode
609
610
The set, reset and get functions don't need to be documented,
611
documenting the property is sufficient. QDoc will generate a list
612
of the access function that will appear in the property
613
documentation which in turn will be located in the documentation
614
of the class that defines the property.
615
616
The \\property command comment typically includes a \l
617
{brief-command} {\\brief} command. For properties the \l
618
{brief-command} {\\brief} command's argument is a sentence
619
fragment that will be included in a one line description of the
620
property. The command follows the same rules for the
621
description as the \l {variable-command} {\\variable} command.
622
623
\badcode *
624
/\1!
625
\property QPushButton::flat
626
\brief Whether the border is disabled.
627
628
This property's default is false.
629
\1/
630
\endcode
631
632
\target qmlattachedproperty-command
633
\section1 \\qmlattachedproperty
634
635
The \\qmlattachedproperty command is for documenting a QML
636
property that will be attached to some QML type. See
637
\l{Attached Properties and Attached Signal Handlers}
638
{Attached Properties}. The argument is the rest of the line.
639
It must start with the property type, followed by the QML
640
type name where the property is declared, the \c{::}
641
qualifier, and finally the property name.
642
643
For example, to document a boolean QML attached property named
644
\c isCurrentItem for the \c ListView type:
645
646
\badcode *
647
/\1!
648
\qmlattachedproperty bool ListView::isCurrentItem
649
650
This attached property is \c true if this delegate is the current
651
item; otherwise false.
652
653
It is attached to each instance of the delegate.
654
655
This property may be used to adjust the appearance of the current
656
item, for example:
657
658
\snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
659
\1/
660
\endcode
661
662
QDoc includes this attached property on the QML reference page for the
663
\l [QML] {ListView} type.
664
665
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedproperty
666
accepts a QML module identifier as part of its argument.
667
668
\target qmlattachedsignal-command
669
\section1 \\qmlattachedsignal
670
671
The \\qmlattachedsignal command is for documenting an attachable
672
\l{Signal and Handler Event System}{signal}. The \\qmlattachedsignal
673
command is used just like the \l{qmlsignal-command} {\\qmlsignal} command.
674
675
The argument is the rest of the line. It should be the name of the
676
QML type where the signal is declared, the \c{::}
677
qualifier, and finally the signal name. For example, a QML
678
attached signal named \c add() in the \c GridView
679
element is documented like this:
680
681
\badcode *
682
/\1!
683
\qmlattachedsignal GridView::add()
684
This attached signal is emitted immediately after an item is added to the view.
685
\1/
686
\endcode
687
688
QDoc includes this documentation on the QML reference page for the
689
\l GridView element.
690
691
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlattachedsignal accepts
692
a QML module identifier as part of its argument.
693
694
\target qmlvaluetype-command
695
\section1 \\qmlvaluetype
696
697
The \\qmlvaluetype command is for documenting a \l [QtQml]
698
{QML Value Types}{value type} for QML. The command takes
699
a type name as its only argument.
700
701
\\qmlvaluetype is functionally identical to the
702
\l {qmltype-command}{\\qmltype} command. The only difference
703
is that the type will be titled (and grouped) as a
704
\e {QML value type}.
705
706
\target qmlclass-command
707
\section1 \\qmlclass
708
709
This command is deprecated. Use \l{qmltype-command} {\\qmltype}
710
instead.
711
712
\target qmlenum-command
713
\section1 \\qmlenum
714
715
The \\qmlenum command is for documenting a QML enumeration. The command
716
takes a single argument: the full name of the enumeration type, including
717
the parent QML type and, optionally, the QML module.
718
719
The enumerators and their descriptions are documented using
720
\qdoccmd {value} commands.
721
722
For example,
723
724
\badcode *
725
/\1!
726
\qmlenum My.Module::Color::Channel
727
\brief Specifies a color channel in the RGB colorspace.
728
729
\value R
730
Red color channel
731
732
\value G
733
Green color channel
734
735
\value B
736
Blue color channel
737
\1/
738
\endcode
739
740
This generates documentation for an enumeration \e Channel, with three
741
enumerators: \e {Color.R}, \e {Color.G}, and \e {Color.B}. By default,
742
the parent QML type name is used as a prefix for the enumerators.
743
744
If the first argument to the qdoccmd{value} command already includes a
745
prefix, it is used as is:
746
747
\badcode
748
\value Channel.R
749
Red color channel
750
\value Channel.G
751
Green color channel
752
\value Channel.B
753
Blue color channel
754
\endcode
755
756
Here, the enumerators are listed as \e {Channel.R}, \e {Channel.G}, and
757
\e {Channel.B}.
758
759
Alternatively, it's possible to replicate the enumerators' documentation
760
from an existing C++ \qdoccmd {enum} topic, by using the
761
\qdoccmd {qmlenumeratorsfrom} command.
762
763
This command was introduced with Qt 6.10.
764
765
See also \qdoccmd {qmlenumeratorsfrom}.
766
767
\target qmlmethod-command
768
\section1 \\qmlmethod
769
770
The \\qmlmethod command is for documenting a QML method. The
771
argument is the complete method signature, including return
772
type and parameter names and types.
773
774
\badcode *
775
/\1!
776
\qmlmethod void TextInput::select(int start, int end)
777
778
Causes the text from \a start to \a end to be selected.
779
780
If either start or end is out of range, the selection is not changed.
781
782
After having called this, selectionStart will become the lesser, and
783
selectionEnd the greater (regardless of the order passed to this method).
784
785
\sa selectionStart, selectionEnd
786
\1/
787
\endcode
788
789
QDoc includes this documentation on the element reference page for the
790
\l{http://doc.qt.io/qt-5/qml-qtquick-textinput.html#select-method}
791
{TextInput} element.
792
793
\target qmltype-command
794
\section1 \\qmltype
795
796
The \\qmltype command is for documenting a QML type. The command
797
has one argument, which is the name of the QML type.
798
799
If the QML type has an equivalent C++ class, you can specify that class
800
with the \qdoccmd nativetype context command.
801
802
The \l {inqmlmodule-command}{\\inqmlmodule} command documents the
803
QML module the type belongs to. The argument passed to this command
804
must match with a documented \l {qmlmodule-command}{\\qmlmodule}
805
page.
806
807
\badcode *
808
/\1!
809
\qmltype Transform
810
\nativetype QGraphicsTransform
811
\inqmlmodule QtQuick
812
813
\brief Provides a way to build advanced transformations on Items.
814
815
The Transform element is a base type which cannot be
816
instantiated directly.
817
\1/
818
\endcode
819
820
Here, the \e{\\qmltype} comment includes \qdoccmd nativetype
821
to specify that a Transform is the QML counterpart to the
822
C++ class QGraphicsTransform. A \\qmltype comment should
823
always include a \l {since-command} {\\since} command, because all
824
QML types are new. It should also include a \l{brief-command}
825
{\\brief} description. If a QML type is a member of a QML type group,
826
the \\qmltype comment should include one or more \l{ingroup-command}
827
{\\ingroup} commands.
828
829
\note QDoc automatically detects QML singleton types when the corresponding
830
C++ class uses the \c{QML_SINGLETON} macro. For such types, using
831
\qdoccmd {qmltype} is sufficient, as the singleton nature will be detected
832
and documented automatically.
833
834
\target qmlsingletontype-command
835
\section1 \\qmlsingletontype
836
837
The \\qmlsingletontype command is for explicitly documenting a QML singleton type.
838
This command is functionally identical to \l{qmltype-command}{\\qmltype}, but it
839
explicitly marks the type as a singleton regardless of the C++ implementation.
840
841
A QML singleton type ensures only one instance exists in the QML engine.
842
The singleton designation is displayed in the generated documentation with
843
a "(Singleton)" indicator in the title and an explanatory note.
844
845
\badcode *
846
/\1!
847
\qmlsingletontype Settings
848
\inqmlmodule MyApp
849
850
\brief Provides application-wide settings as a singleton.
851
852
The Settings type is a singleton that maintains application
853
configuration. Access it directly without instantiation.
854
\1/
855
\endcode
856
857
For C++ classes that use the \c{QML_SINGLETON} macro, prefer using
858
\qdoccmd {qmltype} instead, as QDoc will automatically detect the singleton
859
nature from the C++ code.
860
861
\target qmlproperty-command
862
\section1 \\qmlproperty
863
864
The \\qmlproperty command is for documenting a QML property. The
865
argument is the rest of the line. The argument text should be the
866
property type, followed by the QML type name, the \c{::}
867
qualifier, and finally the property name. If we have a QML
868
property named \c x in QML type \c Translate, and the property
869
has type \c {real}, the \\qmlproperty for it would look like this:
870
871
\badcode *
872
/\1!
873
\qmlproperty real Translate::x
874
875
The translation along the X axis.
876
\1/
877
\endcode
878
879
QDoc includes this QML property on the QML reference page for the
880
\l [QML] {Translate} type.
881
882
The \l{default-command}{\\default} command is used to document the
883
default value of a property:
884
885
\badcode
886
\qmlproperty real AxisHelper::gridOpacity
887
\default 0.5
888
\endcode
889
890
If the QML property exposes a C++ enum, the QML property is defined
891
with type \c{enumeration}:
892
893
\badcode
894
\qmlproperty enumeration ParticleShape3D::ShapeType
895
\endcode
896
897
Properties with enumeration type and those that hold a bit-wise
898
combination of flags can use the \l{value-command}{\\value} command
899
to document the acceptable values.
900
901
\badcode
902
\qmlproperty enumeration Buffer::textureFilterOperation
903
Specifies the texture filtering mode...
904
\value Buffer.Nearest Use nearest-neighbor filtering.
905
\endcode
906
907
QDoc also accepts a fully qualified property name, including the
908
QML module identifier:
909
910
\badcode
911
\qmlproperty bool QtQuick.Controls::Button::highlighted
912
\endcode
913
914
If specified, the module identifier (above, \c {QtQuick.Controls})
915
must match with the value passed to the \l {inqmlmodule-command}{\\inqmlmodule}
916
command in the associated \\qmltype documentation. If the name of
917
the QML type the property belongs to is unique across all types in
918
the documentation project, the module identifier can be omitted.
919
920
\target qmlsignal-command
921
\section1 \\qmlsignal
922
923
The \\qmlsignal command is for documenting a QML signal.
924
The argument is the rest of the line. The arguments should be: the QML type
925
where the signal is declared, the \c{::} qualifier, and finally the signal
926
name. If we have a QML signal named \c clicked(), the documentation for it
927
would look like this:
928
929
\badcode *
930
/\1!
931
\qmlsignal MouseArea::clicked(MouseEvent mouse)
932
933
This signal is emitted when there is a click. A click is defined as a
934
press followed by a release, both inside the MouseArea.
935
\1/
936
\endcode
937
938
QDoc includes this documentation on the QML reference page for the
939
\l [QML] {MouseArea} type.
940
941
\note Like \l{qmlproperty-command}{\\qmlproperty}, \\qmlsignal
942
accepts a QML module identifier as part of its argument.
943
944
\target qmlmodule-command
945
\section1 \\qmlmodule
946
947
Use the \c{\qmlmodule} command to create a \c QML module page. A QML
948
module page is a collection of QML types or any related material. The
949
command takes an optional \c <VERSION> number argument, and is similar
950
to the \l{group-command}.
951
952
A QML type is associated with a module by adding the
953
\l{inqmlmodule-command}{\\inqmlmodule} command to the comment-block that
954
documents the type. You can link to any member of a QML module using the
955
module name and two colons (\c{::}) prefix.
956
957
\badcode *
958
/\1!
959
A link to the TabWidget of the UI Component is \l {UIComponent::TabWidget}.
960
\1/
961
\endcode
962
963
QDoc generates a page for the module that lists all the members of the
964
module.
965
966
\badcode *
967
/\1!
968
\qmlmodule ClickableComponents
969
970
This is a list of the Clickable Components set. A Clickable component
971
responds to a \c clicked() event.
972
\1/
973
\endcode
974
975
\target inqmlmodule-command
976
\section1 \\inqmlmodule
977
978
A QML type is marked as being available under a specific QML module
979
import by inserting the \\inqmlmodule command in a
980
\l {qmltype-command}{\\qmltype} topic. The command takes the module
981
(import) name, without a version number, as the only argument.
982
983
The QML module name must match with a QML module documented with
984
the (\l{qmlmodule-command}{\\qmlmodule} command).
985
986
\badcode *
987
/\1!
988
\qmltype ClickableButton
989
\inqmlmodule ClickableComponents
990
991
A clickable button that responds to the \c click() event.
992
\1/
993
\endcode
994
995
QDoc outputs a row \e {Import statement: import <qmlmodule>}
996
in a table at the top of the QML type reference page.
997
998
When linking to QML types, the QML module identifier may appear in
999
the link target. For example:
1000
1001
\badcode
1002
\l {ClickableComponents::}{ClickableButton}
1003
\endcode
1004
1005
Links to the type reference page, with \e ClickableButton as the
1006
link text.
1007
1008
\target instantiates-command
1009
\section1 \\instantiates
1010
1011
The \\instantiates command is deprecated since Qt 6.8.
1012
Use \qdoccmd nativetype instead.
1013
1014
1015
\target nativetype-command
1016
\section1 \\nativetype
1017
1018
The \\nativetype-command must be used in conjunction with the
1019
\qdoccmd qmltype topic command. The command takes a C++ class as its
1020
argument. If QDoc cannot find the C++ class, it issues a warning. This
1021
command was introduced with Qt 6.8.
1022
1023
Use the \\nativetype-command to specify what the type is called in C++.
1024
This ensures that the requisites block generated in the documentation for
1025
the QML type contains an "In C++" entry. The C++ class will have a
1026
corresponding "In QML" entry.
1027
1028
Any one QML type can only have one native type. QDoc issues a warning if
1029
redefinition occurs. However, multiple QML types can have the same C++
1030
class as their native type. The C++ class documentation will contain a list
1031
of all corresponding types in QML.
1032
1033
\badcode *
1034
/\1!
1035
\qmltype Transform
1036
\nativetype QGraphicsTransform
1037
\inqmlmodule QtQuick
1038
1039
\brief Provides a way to build advanced transformations on Items.
1040
1041
The Transform element is a base type which cannot be
1042
instantiated directly.
1043
\1/
1044
\endcode
1045
1046
Here, the \e{\\qmltype} topic includes \e{\\nativetype} to specify that a
1047
Transform is called QGraphicsTransform in C++.
1048
1049
1050
\target typealias-command
1051
\section1 \\typealias
1052
1053
The \\typealias command is similar to \l {typedef-command}{\\typedef},
1054
but specific to documenting a C++ type alias:
1055
1056
\code
1057
class Foo
1058
{
1059
public:
1060
using ptr = void*;
1061
// ...
1062
}
1063
\endcode
1064
1065
This can be documented as
1066
1067
\badcode *
1068
/\1!
1069
\typealias Foo::ptr
1070
\1/
1071
\endcode
1072
1073
The \\typealias command was introduced in QDoc 5.15.
1074
1075
See also \l {typedef-command}{\\typedef}.
1076
1077
\target typedef-command
1078
\section1 \\typedef
1079
1080
The \\typedef command is for documenting a C++ typedef. The
1081
argument is the name of the typedef. The documentation for
1082
the typedef will be included in the reference documentation
1083
for the class, namespace, or header file in which the typedef
1084
is declared. To relate the \\typedef to a class, namespace, or
1085
header file, the \\typedef comment must contain a
1086
\l {relates-command} {\\relates} command.
1087
1088
\badcode *
1089
/\1!
1090
\typedef QObjectList
1091
\relates QObject
1092
1093
Synonym for QList<QObject>.
1094
\1/
1095
\endcode
1096
1097
Other typedefs are located on the reference page for the class
1098
that defines them.
1099
1100
\badcode *
1101
/\1!
1102
\typedef QList::Iterator
1103
1104
Qt-style synonym for QList::iterator.
1105
\1/
1106
\endcode
1107
1108
See also \l {typealias-command}{\\typealias}.
1109
1110
\target variable-command
1111
\section1 \\variable
1112
1113
The \\variable command is for documenting a class member variable
1114
or a constant. The argument is the variable or constant name. The
1115
\\variable command comment includes a \l {brief-command} {\\brief}
1116
command. QDoc generates the documentation based on the text from
1117
\\brief command.
1118
1119
The documentation will be located in the in the associated class,
1120
header file, or namespace documentation.
1121
1122
In case of a member variable:
1123
1124
\badcode *
1125
/\1!
1126
\variable QStyleOption::palette
1127
\brief The palette that should be used when painting
1128
the control
1129
\1/
1130
\endcode
1131
1132
You can also document constants with the \\variable command. For
1133
example, suppose you have the \c Type and \c UserType constants in
1134
the QTreeWidgetItem class:
1135
1136
\code
1137
enum { Type = 0, UserType = 1000 };
1138
\endcode
1139
1140
For these, the \\variable command can be used this way:
1141
1142
\badcode *
1143
/\1!
1144
\variable QTreeWidgetItem::Type
1145
1146
The default type for tree widget items.
1147
1148
\sa UserType, type()
1149
\1/
1150
\endcode
1151
1152
\badcode *
1153
/\1!
1154
\variable QTreeWidgetItem::UserType
1155
1156
The minimum value for custom types. Values below
1157
UserType are reserved by Qt.
1158
1159
\sa Type, type()
1160
\1/
1161
\endcode
1162
1163
*/
qttools
src
qdoc
qdoc
doc
qdoc-manual-topiccmds.qdoc
Generated on
for Qt by
1.16.1