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.
    Then qvariant_cast<MyClass*> returns it.
    It works fine under Linux (GCC), but under Windows (mingw) doesn't. It returns just int value with address there.
    I had declarations Q_DECLARE_METATYPE(MyClass*) in class header and qRegisterMetaType<MyClass*>("MyClass*") before cast is performed.

    What I missing?

  • OK. Never mind...
    I found the solution.
    QML part read MyClass pointer from other C++ side, exactly as it is - underlying C++ returned bare <MyClass*>.
    I changed that to QVariant::fromValue(myClassPtr) so now it is properly redirected further.
    Poor Win by the way.

Log in to reply