Unsolved QML does not recognize ENUM returned by C++ Q_INVOKABLE function
-
QML
console.log("model's category is " + converter.getModelCategory(currentIndex))
C++
Q_INVOKABLE Unit::Category getModelCategory(int index) { //TODO put in separate file qDebug() << "getModelCategory is called, Index is " << index; return qobject_cast<Unit *>(CategoryDataModel.at(index))->category(); }
error
: Error: Unknown method return type: Unit::Category
whereUnit::Category
is C++ enums and it is declared withQ_ENUM
. However,Unit::Category
is declared in other QOBJECT derived class, might it be a problem?
How to solve this issue? -
As far as I know, "Unit" type need to register throgh qmlRegisterType to make "Unit::Category" visible in QML.