I need it for returning my custom point type with specialized methods by value, not pointer, from C++ Q_INVOKABLE
method to QML. I cannot return pointer because new points are created many times during calculations and its must be destroyed just after using.
Asked
Active
Viewed 264 times
1

dm-kiselev
- 177
- 1
- 9
-
2Since Qt 5.5 you can use `Q_GADGET` to define value types. See [this question](http://stackoverflow.com/q/31433260/2538363) and, most importantly, the link in the answer. – BaCaRoZzo Jul 07 '16 at 13:42
-
I got a message "Unknown method return type" from QML when returning my `Q_GADGET` object. – dm-kiselev Jul 07 '16 at 14:25
-
Do I need calling `qmlRegisterType` or `qmlRegisterUncreatableType` for my type? – dm-kiselev Jul 07 '16 at 14:29
-
Did you `Q_DECLARE_METATYPE`-ed it as in the documentation? The code from the question works out of the box. – BaCaRoZzo Jul 07 '16 at 14:35
-
Yes, I did. It was just another error in my code. Now all works fine. Thanks! – dm-kiselev Jul 07 '16 at 15:37