Doc: Use Qml DefaultProperty as example for Q_CLASSINFO

Setting a DefaultProperty is arguably something
more useful to people than the 'made up' version example.

Also add more links to the relevant QML pages.

Pick-to: 6.6
Change-Id: Id967df7ddf81511299f95b9fd24f56af671fb855
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 98ba0d4e95353febd5a4b14fe2eb9cbd4259bf0a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Kai Köhne 2023-12-19 10:22:28 +01:00 committed by Qt Cherry-pick Bot
parent 3b3960c9b4
commit a91423d4ce
3 changed files with 14 additions and 9 deletions

View File

@ -96,7 +96,7 @@ object->setProperty("priority", "VeryHigh");
//! [7]
Q_CLASSINFO("Version", "3.0.0")
Q_CLASSINFO("DefaultProperty", "content")
//! [7]
//! [8]

View File

@ -277,7 +277,9 @@
Connected to the property system is an additional macro,
Q_CLASSINFO(), that can be used to attach additional
\e{name}--\e{value} pairs to a class's meta-object, for example:
\e{name}--\e{value} pairs to a class's meta-object. This is
used for instance to mark a property as the \e default one
in the context of \l{QML Object Types}:
\snippet code/doc_src_properties.cpp 7
@ -299,5 +301,5 @@
and the general tips on implementing and using
\l {Qt Bindable Properties}{bindable properties}.
\sa {Qt Bindable Properties}
\sa {Qt Bindable Properties}, {Defining QML Types from C++}
*/

View File

@ -4417,19 +4417,22 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\relates QObject
This macro associates extra information to the class, which is available
using QObject::metaObject(). Qt makes only limited use of this feature in
\l{Qt D-Bus} and \l{Qt Qml} modules.
The extra information takes the form of a \a Name string and a \a Value
literal string.
using QObject::metaObject(). The extra information takes the form of a
\a Name string and a \a Value literal string.
Example:
\snippet code/src_corelib_kernel_qobject.cpp 35
Qt makes use of the macro in \l{Qt D-Bus} and \l{Qt Qml} modules.
For instance, when defining \l{QML Object Types} in C++, you can
designate a property as the \e default one:
\snippet code/doc_src_properties.cpp 7
\sa QMetaObject::classInfo()
\sa {Using Qt D-Bus Adaptors}
\sa {Extending QML}
\sa {Defining QML Types from C++}
*/
/*!