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 pass QJsonArray Data to Qml
Forum Updated to NodeBB v4.3 + New Features

How To pass QJsonArray Data to Qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 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.
  • R Offline
    R Offline
    Raji
    wrote on last edited by
    #1
    QJsonArray   m_DataSourceArray = m_DataSourceObject.value(QString("camera")).toArray();
    

    QJsonArray([{"active":true,"buswidth":16,"freqency":0,"height":720,"htotal":2000,"name":"CAM1","pattern":0,"period":33300,"pixelformat":10,"scale":4,"vtotal":1100,"width":1280},{"active":false,"buswidth":16,"freqency":0,"height":720,"htotal":2000,"name":"CAM2","pattern":0,"period":33300,"pixelformat":10,"scale":4,"vtotal":1100,"width":1280}])

    how to display this data in Qml?

    Thanks,

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

      You can send QJsonArray as QVariantList and on QML side it is automatically converted to JS array. Same for JSON objects, they become JS objects.

      So you can just send this array to QML via whatever mechanism you are using, store it in a property var and then use that variable to display your data in UI.

      (Z(:^

      R 1 Reply Last reply
      5
      • sierdzioS sierdzio

        You can send QJsonArray as QVariantList and on QML side it is automatically converted to JS array. Same for JSON objects, they become JS objects.

        So you can just send this array to QML via whatever mechanism you are using, store it in a property var and then use that variable to display your data in UI.

        R Offline
        R Offline
        Raji
        wrote on last edited by
        #3

        @sierdzio : Thanks

        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