Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.4.0
-
None
Description
Given some enums:
#pragma once #include <QObject> struct MyEnums { Q_GADGET public: enum NumberEnum { Zero, One, Two, Three }; Q_ENUM(NumberEnum) enum LetterEnum { aaa, bbb, ccc, ddd }; Q_ENUM(LetterEnum) enum LetterEnum2 { Aaa, Bbb, Ccc, Ddd }; Q_ENUM(LetterEnum2) };
Registered as normal:
#include <QGuiApplication> #include <QQuickView> #include "enumfile.h" int main(int argc, char** argv) { QGuiApplication app(argc, argv); qmlRegisterUncreatableType<MyEnums>("MyLib", 1, 0, "MyEnums", "MyEnums can not be instantiated"); QQuickView view; view.setSource(QUrl("main.qml")); view.show(); return app.exec(); }
Allowed use is inconsistent:
import QtQuick 2.3 import MyLib 1.0 Item { width: 400 height: 400 QtObject { id: theObject property int enumValue: MyEnums.ccc } Text { anchors.centerIn: parent text: { return "Enum MyEnums.Two is " + MyEnums.Two + "\nEnum MyEnums.aaa is " + MyEnums.ccc + "\nEnum MyEnums.Ccc is " + MyEnums.Ccc + "\ntheObject.enumValue is " + theObject.enumValue } } }
shows
Enum MyEnums.Two is 2 Enum MyEnums.aaa is undefined Enum MyEnums.Ccc is 2 theObject.enumValue is 2
Existing code can contain enums which start with a lower-case prefix.
Attachments
Issue Links
- is duplicated by
-
QTBUG-15456 Enumerators whose name begin with a non-capital letter are undefined in QML
-
- Closed
-
-
QTBUG-35494 cpp's enums in QML can't start with a lower case character
-
- Closed
-
-
QTBUG-50429 Make better error message for Q_ENUM with lower-case value names
-
- Closed
-