How to use own enum with Q_INVOKABLE and namespace
Unsolved
QML and Qt Quick
-
wrote on 3 Feb 2018, 12:38 last edited by Bernando 2 Mar 2018, 12:40
Hi,
i will use this function from qml.Q_INVOKABLE bool startBackUp(SomeEnum i);
The Enum is definied in *. h file:
namespace MyNamespace { Q_NAMESPACE enum class SomeEnum { Foo, Bar }; Q_ENUM_NS(SomeEnum) }
I did the registration (``` qmlRegisterUncreatableMetaObject(MyNamespace::staticMetaObject, ..."MyNamespace", ```)
Im write the ```
"import myImort 1.0"
Is use the function in qml:
Model.startBackUp( MyNamespace.Foo) // works not! console.log("MyEnums: " + MyNamespace.Foo + " " + MyNamespace.bar ) // works: MyEnums: 0 1
I get the Message: ```
Error: Unknown method parameter type: MyNamespace.Fooit works fine if i using an Integer datatype: ```
Q_INVOKABLE bool startBackUp(int i); // works Model.startBackUp( MyNamespace.Foo) // works
-
Hi,
Do you also call Q_DECLARE_METATYPE and qRegisterMetaType ?
-
wrote on 4 Feb 2018, 12:09 last edited by Bernando 2 Apr 2018, 12:09
Yes i do.
The console.log works fine. And also with Integer.
Only here I get the errror message:
Q_INVOKABLE bool startBackUp(SomeEnum i); ``` //Error: Unknown method parameter type: MyNamespace.Foo
1/3