Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0
-
None
Description
We have a problem when we can't expose enums to qml.
Our current setup is the following:
We have multiple headers that contain c++ enums, unfortunately we cannot merge them into one:
// HeaderE1.hh namespace bda { enum E1 { E1_1, E1_2, }; }
// HeaderE2.hh namespace bda { enum E2 { E2_1, E2_2, }; }
Then we want to expose these enums to QML, since Q_NAMESPACE can only be used once, we are doing that in a single header like so:
// HeaderQml.hh #include "HeaderE1.hh" #include "HeaderE2.hh" namespace bda { Q_NAMESPACE Q_ENUM_NS(E1) Q_ENUM_NS(E2) } class BDAEnumsQml : public QObject { Q_OBJECT QML_ELEMENT QML_EXTENDED_NAMESPACE(bda) QML_UNCREATABLE("This is a wrapper for exposing enums to QML, do not create instances of this class.") };
But with this setup, the values are not correctly exported to qml and we don't see the enums in .qmltypes file. This works if we move enums to HeaderQml.hh, but unfortunately we cannot do that.
Do you have any suggestions how to fix this?