[Development] Best-practice data type to pass JSON data between C++ and QML

Matt Broadstone mbroadst at gmail.com
Wed Aug 7 21:40:48 CEST 2013


On Wed, Aug 7, 2013 at 3:22 PM, Knoll Lars <Lars.Knoll at digia.com> wrote:

> Right now, they are probably the best you can get. Let's see if we can do
> something better in the future.
>
>
Is there any crossover between the work on v4m and the QJson classes you
wrote for qt5? Or useable representations in v4m that could replace those
QJson classes? I'm writing this having not read through that code at all,
but if its possible it seems like that would be cool.

Cheers,
Matt


> On 8/7/13 5:17 PM, "Milian Wolff" <mail at milianw.de> wrote:
>
> >Hey there!
> >
> >What data type is the most efficient to pass JSON data between C++ and
> >QML? Is
> >there one which does not incur any conversions at all? I tried with
> >QVariantMap and QJsonObject, both work more or less equally well I think.
> >Are
> >both the best you can get?
> >
> >I'm interested in both ways btw., i.e.:
> >
> >test.qml
> >Item {
> >  function foo() {
> >    for(var i in myObj.data) {
> >      console.log(i, myObj.data[i]);
> >    }
> >    myObj.data = {foo: "bar", asdf: 42.0};
> >}
> >
> >
> >MyObj.h
> >
> >typedef JSONData ?;
> >
> >class MyObj : public QObject {
> >  Q_OBJECT
> >  Q_PROPERTY(data READ data WRITE setData NOTIFY dataChanged)
> >public:
> >  JSONData data() const;
> >  void setData(const JSONData& data) const;
> >signals:
> >  void dataChanged(JSONData);
> >};
> >
> >Thanks
> >--
> >Milian Wolff
> >mail at milianw.de
> >http://milianw.de
> >_______________________________________________
> >Development mailing list
> >Development at qt-project.org
> >http://lists.qt-project.org/mailman/listinfo/development
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130807/d3f92847/attachment.html>


More information about the Development mailing list