diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-11-01 15:56:35 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-11-10 15:00:11 +0100 |
commit | 42065c0e6eba377d775908affdd2a98805712b13 (patch) | |
tree | e5ae21bf3cebd0f8312a73cefff5124eb701d3c9 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
parent | c337db8d7ee77ea3aaafd6a065a34865319dbe5e (diff) | |
download | qtdeclarative-42065c0e6eba377d775908affdd2a98805712b13.tar.gz |
QQmlComponent::loadFromModule: Support inline components
QQmlComponent already has support to load sub-objects in a QML file
(which is necessarry for the QtQml Component type).
We repurpose the same code path to load inline components. However, we
need to remember that we are dealing with an inline component (instead of
a Component), as the QmlObjectCreator requires a specific flag to
correctly instantiate the inline component in that case.
Everything else is however handled by calling QQmlComponent::load with
the URL of the outer type.
Except for one additional gotcha: The QQmlType of the inline component
might only contain a placeholder id if the outer component has not been
loaded so far (as we cannot possibly know the object's id inside the
file without compiling it). To get the correct id, we force synchronous
loading if we detect that we've gotten a placeholder type (id <= -2).
In the future, we might want to remember either the URL or the QQmlType
to avoid forcing a synchronous load. Then we could set "start" to the
correct object id in beginCreate.
Change-Id: I20209e9389d0a64d2a07c2fb1bc9cbc430668040
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
0 files changed, 0 insertions, 0 deletions