Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.5.8, 6.8.2, 6.9.0 Beta2
-
Windows 10 22H2, MSVC 2022 x64, MinGW x64
-
fd88f44c1 (dev), 0f4cd43bc (6.9), c170381f3 (dev), aed070931 (6.8)
Description
See attached project. The CppObj class contains both Q_OBJECT and QML_ELEMENT. The relevant headers for those macros are precompiled but not explicitly #include-d.
The Clang code model is happy with the C++ code (when using MSVC) and the project does not produce any compile-time errors. But, it contains runtime errors:
- CppObj::metaObject() is implemented by moc and can be called in C++ (Expected)
- CppObj is not registered as a QML type and is invisible to the QML engine (Not Expected)
Workaround
Explicitly #include-ing the PCH (or <qqmlintegration.h>) fixes the error.