aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.h
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@qt.io>2020-06-15 08:24:33 +0200
committerFawzi Mohamed <fawzi.mohamed@qt.io>2020-08-27 10:21:26 +0200
commit0028b176981b4ac2361b2d377b478791b0d40d4f (patch)
tree1ba02970ec70f7e9442f775f3a3c60c33ae554d9 /src/qml/qml/qqml.h
parent16613f3741af013f7e380c98df6889d73512d0ad (diff)
import Qt namespace in QtQml
Introduces and uses the QML_FOREIGN_NAMESPACE to declare the Qt namespace in QtQml, and exports all the enumerations in the Qt namespace, and makes them available also in QtQml/plugins.qmltypes Please note that this does *not* remove the special QV4::QtObject as it contains much more than the enumerations. Having two object registered as Qt (the complete QV4::QtObject added to the global properties in ExecutionEngine::initializeGlobal, and QtInQml registered by the qmltyperegistrar) gives problems, if the partial one overrides the complete one. For this reason the classinfo QML.ManualRegistration (no public macro until shown to be more generally useful) is introduced and used to ensure that QtInQml generates only documentation (plugins.qmltypes), and no registration that might conflict with QtObject. This makes the current builtins.qmltypes redundant. Fixes: QTBUG-84897 Change-Id: Iffc96cd3e1d9f9d7d047ee60221a4b0928f53005 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r--src/qml/qml/qqml.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index bd608c5c99..0d474d6c4e 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -125,6 +125,9 @@
template<typename T, typename... Args> \
friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *);
+#define QML_FOREIGN_NAMESPACE(FOREIGN_NAMESPACE) \
+ Q_CLASSINFO("QML.Foreign", #FOREIGN_NAMESPACE)
+
#define QML_INTERFACE \
Q_CLASSINFO("QML.Element", "anonymous") \
enum class QmlIsInterface {yes = true}; \
@@ -850,8 +853,10 @@ inline void qmlRegisterTypesAndRevisions<>(const char *, int, QList<int> *)
{
}
-inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject, const char *uri,
- int versionMajor, QList<int> *qmlTypeIds = nullptr)
+inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject,
+ const char *uri, int versionMajor,
+ QList<int> *qmlTypeIds = nullptr,
+ const QMetaObject *classInfoMetaObject = nullptr)
{
QQmlPrivate::RegisterTypeAndRevisions type = {
0,
@@ -865,7 +870,7 @@ inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject, cons
QTypeRevision::fromMajorVersion(versionMajor),
metaObject,
- metaObject,
+ (classInfoMetaObject ? classInfoMetaObject : metaObject),
nullptr,
nullptr,