Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to unpack all the data's in C++ of type QVariant that send from QML
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    econtech
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

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

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

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved