Suppose I have some class that derives from QObject:
Q_OBJECT
// ...
};
class MyTest : public QObject {
Q_OBJECT
// ...
};
To copy to clipboard, switch view to plain text mode
And I want to return pointer to this class from Q_INVOKABLE function, like this:
Q_INVOKABLE MyTest *createMyTest(){
return new MyTest();
}
Q_INVOKABLE MyTest *createMyTest(){
return new MyTest();
}
To copy to clipboard, switch view to plain text mode
However, when I try to invoke this method from the script in QJSEngine, I get the following error:
Error: Unknown method return type: MyTest*
Error: Unknown method return type: MyTest*
To copy to clipboard, switch view to plain text mode
If I make createMyTest() to return QObject* instead of MyTest*, it works. But of course this would force me to use casts, which I'd like to avoid. So, how to make it work with MyTest*?
Just by chance, I tried to declare metatype, as follows:
Q_DECLARE_METATYPE(MyTest*)
Q_DECLARE_METATYPE(MyTest*)
To copy to clipboard, switch view to plain text mode
But this didn't help.
Thanks in advance.
Bookmarks