Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
6.4.2
-
None
-
MacOS (Apple Silicon) 12.6.5, CMake 3.24, Apple clang version 14.0.0 (clang-1400.0.29.202)
Description
My understanding is that as of Qt 6.2 there is no need to manually register QML types, but that the macros will do that for us. Indeed that has been my experience, using several QML_ELEMENT and Q_GADGET classes.
However enums only get recognised in QML for QML_ELEMENTs.
I have attached a minimal example containing:
- A class derived from QObject, that has Q_OBJECT, QML_ELEMENT and Q_ENUM
- A class that has Q_GADGET and Q_ENUM
- A namespace that has Q_NAMESPACE and Q_ENUM_NS
Of these three, only the first results in an enum that works in QML.
I notice, looking at the resulting build folder, that mymodulelib_qmltyperegistrations.cpp only registers the module and the QObject; and that MyModuleLib.qmltypes only contains the enum of the Object.
Attachments
Issue Links
- duplicates
-
QTBUG-108883 Improve documentation on how to expose value types with enums to QML
- Closed
-
QTBUG-113188 No explaination, no example on how to use C++ enmus in QML right way in Qt6
- Closed