Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
6.6.2, 6.7.0
-
None
Description
I have a first library that defines a namespace like:
namespace WarningState { Q_NAMESPACE_EXPORT(HELPLIB_EXPORT) enum class State { Unknown, Information, Warning, Error, Success }; Q_ENUM_NS(State); } // namespace WarningState
Then In a QML reusable module, I want to register it to be able to use the enum in QML code.
For that I added this to my module:
namespace WarningStateForeign { Q_NAMESPACE QML_NAMED_ELEMENT(WarningState) QML_FOREIGN_NAMESPACE(WarningState) };
The code generated does not build.
Here is the generated code:
Q_QMLTYPE_EXPORT void qml_register_types_Help() { qmlRegisterTypesAndRevisions<HelpNotificationListModelForeign>("Help", 1); QMetaType::fromType<WarningState>().id(); qmlRegisterNamespaceAndRevisions(&WarningState::staticMetaObject, "Help", 1, nullptr, &WarningStateForeign::staticMetaObject, nullptr); qmlRegisterModule("Help", 1, 0); }
The error is on line
QMetaType::fromType<WarningState>().id();
WarningState is an enum. If I remove this line of code it works correctly and everything is correctly registered to QML.
If I move the namespace definition in the QML module (instead of beeing in a separated library) it also works.
Attachments
Issue Links
- relates to
-
QTBUG-118112 Create doc pages that explain how to fix qmllint/qmlsc warnings (take 2)
- Closed