Q_ENUMS problem
-
I have problems with exposing c++ enum to QML
C++ code:
@
class MyClass : public QDeclarativeView
{Q_OBJECT Q_ENUMS(Tasks)
public:
enum Tasks { Task1, Task2, Task3 };
}
@I also send the object to the qml:
@
this->rootContext()->setContextProperty("myclass", this);
@
QML code:
@
Rectangle {
anchors.fill: parentMouseArea { anchors.fill: parent onClicked: { console.log("enum:" + myclass.Task1); } } }
@
I should get "enum:0" in log, but it displays "enum: undefined".Any idea what am I doing wrong?
[edit: code highlighted / Denis Kormalev]
-
You should make qml know about your class with qmlRegisterType or qmlRegisterUncreatableType.