From 684f9df7849bc79f1f02a60844fb43c7a3927d2f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 15 Jan 2020 14:47:35 +0100 Subject: Long live QML inline components [ChangeLog][QtQml] It is now possible to declare new QML components in a QML file via the component keyword. They can be used just as if they were declared in another file, with the only difference that the type name needs to be prefixed with the name of the containing type outside of the file were the inline component has been declared. Notably, inline components are not closures: In the following example, the output would be 42 // MyItem.qml Item { property int i: 33 component IC: Item { Component.onCompleted: console.log(i) } } // user.qml Item { property int i: 42 MyItem.IC {} } Fixes: QTBUG-79382 Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5 Reviewed-by: Ulf Hermann --- src/qml/qml/qqmlobjectcreator_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlobjectcreator_p.h') diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 8b6cb67341..f8ad90be15 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -111,7 +111,8 @@ public: QQmlObjectCreator(QQmlContextData *parentContext, const QQmlRefPointer &compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = nullptr); ~QQmlObjectCreator(); - QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, QQmlInstantiationInterrupt *interrupt = nullptr); + enum CreationFlags { NormalObject = 1, InlineComponent = 2 }; + QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, QQmlInstantiationInterrupt *interrupt = nullptr, int flags = NormalObject); bool populateDeferredProperties(QObject *instance, const QQmlData::DeferredData *deferredData); -- cgit v1.2.3