[Interest] QML ListModels and JSON

Daniel França daniel.franca at gmail.com
Wed Mar 25 21:45:39 CET 2015


I used the JSONListModel for a project, the code is available under MIT
license here: https://github.com/kromain/qml-utils

Em qua, 25 de mar de 2015 às 20:58, Jason H <jhihn at gmx.com> escreveu:

> I get back from a Ajax a JSON object with a 'table' from a web query:
> [
> {id: 1, "category":"1", value:"1"},
> {id: 2, "category":"1", value:"2"},
> {id: 3, "category":"2", value:"3"},
> ...
> ]
>
> What is the easiest way to convert the array to ListElements?
> Up to this point, I was copying data using ListModel.append() but I was
> hoping there was an implicit conversion:
>
> listModel = rows; // where rows = [... the array above... ]
>
> I was also looking for a way to create a model of the distinct values of
> category. I realize there are sections within a ListView, but I want an
> actual model.
>
>
> THanks.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150325/2ad98848/attachment.html>


More information about the Interest mailing list