-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.12.0
-
None
It is impossible to re-use the C++ enumerations for the Qml.
F.e. I have somewhere the following C++ enum from the external source (library, package, etc):
namespace origin {
enum class State {
Foo,
Bar,
Baz,
};
} // namespace origin
And then I want to re-use this enum to use it from the Qml:
namespace reused {
Q_NAMESPACE
using State = ::origin::State; // Here I'm try to re-use the origin::State enum for Qml
Q_ENUMS(State) // or Q_ENUM_NS(State)
} // namespace reused
Q_DECLARE_METATYPE(reused::State)
And then I do register the `reused` namespce metatype from the C++ code:
qmlRegisterUncreatableMetaObject(reused::staticMetaObject, "my.test", 1, 0, "Reused", "Error: only enums");
In Qml I expect that I will able to access to the `Reused.Foo` value from the Qml code:
Window {
width: 640
height: 480
visible: true
property bool dummy: {
console.info("** state: " + myobj.state)
console.info("** foo: " + Reused.Foo)
return false;
}
}
But, it prints out the following:
qml: ** state: 0 qml: ** foo: undefined
The MOC (or something else) does not parse the `using` or `typedef` keywords or etc...
UPD: I have attached the qbsbug-99257.zip source example to reproduce an issue.