aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/doc/src/qml-extending.qdoc
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-12 17:03:52 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-01-13 16:47:57 +0100
commit2c3419e127e55810da1741725b4ff39f118cd577 (patch)
tree670ec93d28dadad06bd840a5694935ef8a7b2ac0 /examples/qml/doc/src/qml-extending.qdoc
parent4eff7299501ff932071300b3fa34fbeccb03d0d8 (diff)
Generate registrations for all examples
Now that we can generate all QML type information at build time, we should also use it. Change-Id: I647c72bbe38fdb2deb565b75c86a696af3d15b61 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'examples/qml/doc/src/qml-extending.qdoc')
-rw-r--r--examples/qml/doc/src/qml-extending.qdoc15
1 files changed, 6 insertions, 9 deletions
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc
index 64d7235031..1ad3ae9a10 100644
--- a/examples/qml/doc/src/qml-extending.qdoc
+++ b/examples/qml/doc/src/qml-extending.qdoc
@@ -52,10 +52,6 @@ type, the C++ class can be named differently, or appear in a namespace.
The Person class implementation is quite basic. The property accessors simply
return members of the object instance.
-The \c main.cpp file also calls the \c qmlRegisterType() function to
-register the \c Person type with QML as a type in the People library version 1.0,
-and defines the mapping between the C++ and QML class names.
-
\section1 Running the Example
The main.cpp file in the example includes a simple shell application that
@@ -77,9 +73,11 @@ Shows how to use \l {QQmlEngine::}{qmlRegisterExtendedType()} to provide an
\l {Registering Extension Objects}{extension object} to a \l QLineEdit without modifying or
subclassing it.
-Firstly, the LineEditExtension class is registered with the QML system as an extension of QLineEdit:
+Firstly, the LineEditExtension class is registered with the QML system as an
+extension of QLineEdit. We declare a foreign type to do this as we cannot modify
+Qt's internal QLineEdit class.
-\snippet referenceexamples/extended/main.cpp 0
+\snippet referenceexamples/extended/lineedit.h 0
The QML engine then instantiates a \l QLineEdit:
@@ -182,9 +180,8 @@ directly - an explicit Boy or Girl should be instantiated instead.
While we want to disallow instantiating Person from within QML, it still needs
to be registered with the QML engine, so that it can be used as a property type
-and other types can be coerced to it.
-
-\snippet referenceexamples/coercion/main.cpp 0
+and other types can be coerced to it. This is what the QML_UNCREATABLE macro
+does.
\section2 Define Boy and Girl