Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
6.5.2
-
None
Description
The code below was the recommended way to define enums in Q_GADGET's that can be used in QML. However, with this setup qmllint is incorrectly (I believe) issuing a warning for unqualified access.
The C++ types are defined as follows:
#ifndef TYPES_H #define TYPES_H #include <QtQml/QtQml> //----------------------------------------------------------------------// struct TestGadget { Q_GADGET QML_NAMED_ELEMENT(testGadget) Q_PROPERTY(int value MEMBER value) public: enum class GadgetEnum { OptionA, OptionB, OptionC, }; Q_ENUM(GadgetEnum) public: int value = 0; }; struct TestGadgetDerived : TestGadget { Q_GADGET }; namespace TestGadgetEnums { Q_NAMESPACE QML_FOREIGN_NAMESPACE(TestGadgetDerived) QML_NAMED_ELEMENT(TestGadget) } // namespace TestGadgetEnums #endif
QML:
...
Component.onCompleted: {
console.log("TestGadget.GadgetEnum.OptionC = " + TestGadget.GadgetEnum.OptionC)
}
...
qmllint generates the following warning:
app_test_qml_application.qml:117:54: warning: Unqualified access [unqualified] console.log("TestGadget.GadgetEnum.OptionC = " + TestGadget.GadgetEnum.OptionC) ^^^^^^^^^^
I am seeing this with a skeleton project in QtCreator