Document lack of qmlContext/qmlEngine in module API classes
authorMatthew Vogt <matthew.vogt@nokia.com>
Mon, 16 Jul 2012 05:59:06 +0000 (15:59 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 16 Jul 2012 21:14:39 +0000 (23:14 +0200)
Task-number: QTBUG-23116

Change-Id: Ia6620b4046ac3e72c8b304633fcad40cf0efe2ed
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
src/qml/doc/src/qmlfunctions.qdoc

index e8f6e5f..cf3527c 100644 (file)
        }
    }
    \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
+
   */