Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How To pass QJsonArray Data to Qml



  • 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,


  • Moderators

    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.



  • @sierdzio : Thanks


Log in to reply