How to unpack all the data's in C++ of type QVariant that send from QML



  • I am sending QVariant from QML to C++. The QVarient having the following types.

    QVariant(QVariantList, (QVariant(QObject*, Marker_QMLTYPE_3(0x2e5c33b8) ) ) )

    I want to access all the properties of QObject's from the QVariant. I struct with the problem for last two days.
    How can I unpack the data from the QVariant having QVariant list of QObject. Its very helpful any one of you help me,how i can proceed.

    Thanks In Advance


  • Moderators

    Try this:
    @
    QVariant qmlData;
    QVariantList temp = qmldata.value<QVariantList>();

    foreach (QVariant var, temp) {
    QObject *myObject = var.value<QObject *>();

    if (myObject) {
    // yay!
    }
    }
    @


Log in to reply
 

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