Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.6.1
-
-
8896d380a (dev), 40cde2552 (6.7), 0e4d4d4a4 (6.6), 385436f2a (tqtc/lts-6.5)
Description
#pragma once #include <QtQuick/QQuickItem> class CppItem : public QQuickItem { Q_OBJECT QML_ELEMENT Q_PROPERTY(QString text MEMBER text) private: QString text; auto componentComplete() -> void final { QQuickItem::componentComplete(); qDebug() << "componentComplete" << text; } };
#include <QtQuick> #include "cppitem.hpp" int main(int argc, char **argv) { QGuiApplication app(argc, argv); QQuickWindow window; QQmlEngine engine; { QQmlComponent component{&engine}; component.setData("import App; CppItem {}", {}); component.createWithInitialProperties(QVariantMap{{"text", "load from data"}}); } { QQmlComponent component{&engine}; component.loadFromModule("App", "CppItem"); component.createWithInitialProperties(QVariantMap{{"text", "load from module"}}); } return 0; }
Here, same type QML item CppItem created twice, first one is using QQmlComponent::setData() and second one is using QQmlComponent::loadFromModule().
Here's the result:
19:47:01: Starting path\app.exe... QML debugging is enabled. Only use this in a safe environment. componentComplete "load from data" 19:47:01: path\app.exe exited with code 0
As you can see, componentComplete() is not called for the one created by QQmlComponent::loadFromModule().
Same for classBegin(), so I think QQmlParserStatus is not working for QQmlComponent::loadFromModule().