Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
4.7.4
-
None
Description
A negative enum defined in a C++ class translates as 'undefined' in QML.
#ifndef TEST_H #define TEST_H #include <QtCore> class Test : public QObject { Q_OBJECT public: enum MyEnum { Foo = -1, Foo0 = 0, Foo1 = 1 }; Q_ENUMS(MyEnum) }; #endif // TEST_H
#include <QtGui> #include <QtDeclarative> #include "test.h" int main(int argc, char **argv) { QApplication app(argc, argv); qmlRegisterType<Test>("mylib", 1, 0, "Test"); QDeclarativeView v; v.setSource(QString("test.qml")); v.show(); return app.exec(); }
import QtQuick 1.0 import mylib 1.0 Rectangle { width: 100 height: 62 Component.onCompleted: { console.log("Enum: " + Test.Foo + " " + Test.Foo0 + " " + Test.Foo1); } }
And the output is: Enum: undefined 0 1
while it should be: Enum: -1 0 1.