Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.5.3
-
None
Description
To declare a QML element from C++, one can use QML_ELEMENT with qt_add_qml_module, and it works nicely... until you add precompiled_headers to the mix.
See attached project, the precompiled_headers contains QQmlEngine, and the TestItem is declared as is:
#ifndef TESTITEM_H #define TESTITEM_H #include <QObject> class TestItem : public QObject{ Q_OBJECT QML_ELEMENT public: explicit TestItem(QObject *parent = nullptr); }; #endif // TESTITEM_H
As you can see, QQmlEngine is not included here, and everything compiles fine thanks to precompiled_headers.
But when running, you got this error:
qrc:/qt/qml/test_bug/Main.qml:11:5: TestItem is not a type
TestItem is not in the module... adding the include QQmlEngine fixes it.
As long as the code compile, the QML_ELEMENT tag should be handled properly, even without the QQmlEngine inc;ude.