Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
qvariant_cast - can't retrieve custom class pointer from QML
SeeLook last edited by SeeLook
My QML code reads pointer of custom class and invokes C++ code with this pointer as a parameter.
It works fine under Linux (GCC), but under Windows (mingw) doesn't. It returns just
intvalue with address there.
I had declarations
Q_DECLARE_METATYPE(MyClass*)in class header and
qRegisterMetaType<MyClass*>("MyClass*")before cast is performed.
What I missing?
SeeLook last edited by
OK. Never mind...
I found the solution.
QML part read
MyClasspointer from other C++ side, exactly as it is - underlying C++ returned bare
I changed that to
QVariant::fromValue(myClassPtr)so now it is properly redirected further.
Poor Win by the way.