From b9ba1ed06f63053b6fe5426cc1cc726b6b85592f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 09:22:09 +0200 Subject: Fix documentation for qmlRegisterType and qmlRegisterAnonymousType Plain qmlRegisterType() is deprecated and qmlRegisterAnonymousType() was added in 5.14 as replacement. Also, qmlRegisterAnonymousType() does take an import URI and a major version. The point about non-anonymous type registration is that it also takes an element name. Change-Id: I51fb6f9c63dcf15dc1da10c25ea6c6d3b88fd31a Reviewed-by: Kavindra Palaraja --- src/qml/doc/src/qmlfunctions.qdoc | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/qml/doc') diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index c71d18418a..81aa263fa6 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -276,25 +276,14 @@ /*! \fn int qmlRegisterAnonymousType(const char *uri, int versionMajor) - This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system. + This template function registers the C++ type in the QML system as an anonymous type. The + resulting QML type does not have a name. Therefore, instances of this type cannot be created from + the QML system. You can, however, access instances of the type when they are exposed as properties + of other types. - Use this function when the type will not be referenced by name. Use \a uri and \a versionMajor to indicate to which module the type belongs. - - \sa {Choosing the Correct Integration Method Between C++ and QML} -*/ - -/*! - \fn int qmlRegisterType() - \relates QQmlEngine - \overload - - This template function registers the C++ type in the QML - system. Instances of this type cannot be created from the QML - system. - - This function should be used when the type will not be referenced by name. - Specifically, it has to be used for C++ types that are used as the left-hand - side of a property binding. + Use this function when the type will not be referenced by name, specifically for C++ types that + are used on the left-hand side of a property binding. To indicate to which module the type belongs + use \a uri and \a versionMajor. For example, consider the following two classes: @@ -354,17 +343,28 @@ \code qmlRegisterType("App", 1, 0, "Foo"); - qmlRegisterType(); + qmlRegisterAnonymousType("App", 1); \endcode As the \c Foo type is instantiated in QML, it must be registered - with the version of \l qmlRegisterType() that takes an import URI. + with the version of \l qmlRegisterType() that takes an element name. Returns the QML type id. + \since 5.14 \sa {Choosing the Correct Integration Method Between C++ and QML} */ +/*! + \fn int qmlRegisterType() + \relates QQmlEngine + \overload + \deprecated + + Do not use this function. For anonymous type registrations, use \l qmlRegisterAnonymousType(), + and make sure to provide a URI and a major version. +*/ + /*! \fn int qmlRegisterInterface(const char *typeName) \relates QQmlEngine -- cgit v1.2.3