Solved qvariant_cast - can't retrieve custom class pointer from QML
-
My QML code reads pointer of custom class and invokes C++ code with this pointer as a parameter.
Thenqvariant_cast<MyClass*>
returns it.
It works fine under Linux (GCC), but under Windows (mingw) doesn't. It returns justint
value with address there.
I had declarationsQ_DECLARE_METATYPE(MyClass*)
in class header andqRegisterMetaType<MyClass*>("MyClass*")
before cast is performed.What I missing?
-
OK. Never mind...
I found the solution.
QML part readMyClass
pointer from other C++ side, exactly as it is - underlying C++ returned bare<MyClass*>
.
I changed that toQVariant::fromValue(myClassPtr)
so now it is properly redirected further.
Poor Win by the way.