From 2c3419e127e55810da1741725b4ff39f118cd577 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Sep 2019 17:03:52 +0200 Subject: 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 --- examples/qml/doc/src/qml-extending.qdoc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'examples/qml/doc/src/qml-extending.qdoc') 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 -- cgit v1.2.3