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. QJsonValue javascript integration
Qt 6.11 is out! See what's new in the release blog

QJsonValue javascript integration

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 493 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.
  • P Offline
    P Offline
    Pylvain
    wrote on last edited by
    #1

    Hi,
    I want to make a QJsonValue available to javascript and qml ( QJsonValue can hold any type of Json value, including objects and arrays )
    If I make a Q_INVOKABLE function returning a QJsonValue, will it work ? I'm a bit confused. I read the doc page on data convertion between C++ and QML, but there is nothing about QJsonValue ...

    ODБOïO 1 Reply Last reply
    0
    • P Pylvain

      Hi,
      I want to make a QJsonValue available to javascript and qml ( QJsonValue can hold any type of Json value, including objects and arrays )
      If I make a Q_INVOKABLE function returning a QJsonValue, will it work ? I'm a bit confused. I read the doc page on data convertion between C++ and QML, but there is nothing about QJsonValue ...

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      @Pylvain said in QJsonValue javascript integration:

      If I make a Q_INVOKABLE function returning a QJsonValue, will it work

      You can test it.
      It looks like it is returning the plain JSON string, so you can use JSON.parse() in QML/Js to construct a json object

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Pylvain
        wrote on last edited by
        #3

        I think I solved the thing ! The Javascript engine of Qt, which is inherited by the Qml Engine, works with QJSValue, not QJsonValue. That's practicaly the same thing, and it's well integrated with Qml.

        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