From af4fbcbf901ad0ee48bdd0121769db4dc3c07452 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Mon, 16 Jul 2012 15:59:06 +1000 Subject: [PATCH] Document lack of qmlContext/qmlEngine in module API classes Task-number: QTBUG-23116 Change-Id: Ia6620b4046ac3e72c8b304633fcad40cf0efe2ed Reviewed-by: Chris Adams --- src/qml/doc/src/qmlfunctions.qdoc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index e8f6e5f..cf3527c 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -331,4 +331,29 @@ } } \endqml + + Since Module APIs do not have an associated QQmlContext object, then within the functions of a QObject-derived + type that is registered as a module API implementation the QML context and engine information is not available. + The QQmlEngine::contextForObject() function returns NULL when supplied with a pointer to an QObject that + implements a module API. + + Extending the above example: + + \code + class ModuleApiExample : public QObject + { + ... + + Q_INVOKABLE void doSomethingElse() + { + // QML Engine/Context information is not accessible here: + Q_ASSERT(QQmlEngine::contextForObject(this) == 0); + Q_ASSERT(qmlContext(this) == 0); + Q_ASSERT(qmlEngine(this) == 0); + } + + ... + } + \endcode + */ -- 2.7.4