Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.1, 6.6.0 Beta1
-
c45c32af3 (dev), bc2ae5a70 (dev), 7d01e7ef8 (dev)
Description
Code
// cppbase.h, in submodule #include <QQmlEngine> class CppBase : public QObject { Q_OBJECT QML_ELEMENT public: explicit CppBase(QObject* parent = nullptr) : QObject(parent) {} };
// cppderived.h, in "main" module #include "MyModule/cppbase.h" class CppDerived : public CppBase { Q_OBJECT QML_ELEMENT public: explicit CppDerived(QObject* parent = nullptr) : CppBase(parent) {} };
Compiler output
Warning: Main.qml: Object type CppDerived is not derived from QObject or QQmlComponent. You may need to fully qualify all names in C++ so that moc can see them. You may also need to add qt_extract_metatypes(<target containing >). [compiler]
Workaround
Instead of linking to the plugin target, link directly to the backing target. In other words, replace this...
target_link_libraries(appCrossModuleDerivation PRIVATE Qt6::Quick MyModuleplugin )
...with this:
target_link_libraries(appCrossModuleDerivation PRIVATE Qt6::Quick MyModule )
Attachments
Issue Links
- mentioned in
-
Page Loading...
For Gerrit Dashboard: QTBUG-115152 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
490485,7 | CMake: Expose metatypes internal functions for further use in qml | dev | qt/qtbase | Status: MERGED | -1 | 0 |
490515,10 | CMake: Duplicate backing library metatypes to its associated plugin | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
492090,4 | CMake: Fix installed metatypes not being propagated to other repos | dev | qt/qtbase | Status: MERGED | +2 | 0 |
561060,2 | CMake: Consume transitive metatypes json files when using CMake 3.30 | dev | qt/qtdeclarative | Status: DEFERRED | 0 | 0 |