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

QJsonValue javascript integration



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



  • 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



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


Log in to reply