error: ‘QVariant::QVariant(void*)’ is private inline QVariant(void *) Q_DECL_EQ_DELETE;



  • Hi all

    I am trying to use C++ class in qml using setcontext property method, but when i try to build it it is giving the following error

    /opt/Qt5.8.0/5.8/gcc_64/include/QtCore/qvariant.h:471: error: ‘QVariant::QVariant(void*)’ is private
    inline QVariant(void *) Q_DECL_EQ_DELETE;

    what may be the issue for this? what changes i need to make ?

    thanks



  • You are trying to convert a pointer to a QVariant. You'll have to use QVariant::fromValue() to avoid implicit cast to bool and end up using QVariant(bool).

    T *ptr = ...;
    QVariant v1 = ptr; // not ok
    QVariant v2 = QVariant::fromValue(ptr); // ok

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.