aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/doc/src/qml-extending.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/doc/src/qml-extending.qdoc')
-rw-r--r--examples/qml/doc/src/qml-extending.qdoc17
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc
index e56dd90dd7..723e470d45 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
@@ -73,13 +69,15 @@ This example builds on:
\li \l {Extending QML - Adding Types Example}
\endlist
-Shows how to use \l {QQmlEngine::}{qmlRegisterExtendedType()} to provide an
+Shows how to use \l {QML_EXTENDED} 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:
@@ -178,11 +176,12 @@ previous example. However, as we have repurposed the People class as a common
base for Boy and Girl, we want to prevent it from being instantiated from QML
directly - an explicit Boy or Girl should be instantiated instead.
-\snippet referenceexamples/coercion/main.cpp 0
+\snippet referenceexamples/coercion/person.h 0
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.
+and other types can be coerced to it. This is what the QML_UNCREATABLE macro
+does.
\section2 Define Boy and Girl