Qt 6.11 is out! See what's new in the release
blog
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 justintvalue 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 readMyClasspointer 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.