Error: Unknown method return type
-
Hi,
I have a custom type declared in C++:
class MyType : public QObject { Q_OBJECT ... };
In main.cpp I registered that Type:
qmlRegisterType<MyType>("MyType", 1, 0, "MyType");
Somewhere else I've got a function returning a pointer to that type:
Q_INVOKABLE MyType* getMyType() const { ... }
So far, so good. But when I call the function getMyType() from QML, I get the following error:
Error: Unknown method return type: MyType*
What am I missing?
-
Hi,
I have a custom type declared in C++:
class MyType : public QObject { Q_OBJECT ... };
In main.cpp I registered that Type:
qmlRegisterType<MyType>("MyType", 1, 0, "MyType");
Somewhere else I've got a function returning a pointer to that type:
Q_INVOKABLE MyType* getMyType() const { ... }
So far, so good. But when I call the function getMyType() from QML, I get the following error:
Error: Unknown method return type: MyType*
What am I missing?
-
@DuBu said in Error: Unknown method return type:
What am I missing?
maybe
import MyType 1.0
in you qml?@KroMignon No, I forgot to mention, MyType was already imported.
-
MyType*
andMyType
are different types and must be registered separately. Also it may be better/easier just to returnQObject*
instead ofMyType*
, properties/stots will be visible in QML.