Json parsing into qtreewidget
-
I'm having json format like this.
Json:
[
{ "id": "5001", "type": ["none"] },
{ "id": "5002", "type": ["glazed", "sugar"]},
{ "id": "5003", "type": ["glazed", "chocolate", "sugar"] },
{ "id": "5004", "type": ["powdered sugar", "chocolate", "sugar"] },
{ "id": "5004", "type": ["chocolate with sprinkles", "maple"]},
{ "id": "5005", "type": [" None", "chocolate", "glazed", "sugar", "powdered sugar"] }
]I'm trying to get id values in parent and type values in child in qtree widget.
Please anyone help me with code and example. -
I'm having json format like this.
Json:
[
{ "id": "5001", "type": ["none"] },
{ "id": "5002", "type": ["glazed", "sugar"]},
{ "id": "5003", "type": ["glazed", "chocolate", "sugar"] },
{ "id": "5004", "type": ["powdered sugar", "chocolate", "sugar"] },
{ "id": "5004", "type": ["chocolate with sprinkles", "maple"]},
{ "id": "5005", "type": [" None", "chocolate", "glazed", "sugar", "powdered sugar"] }
]I'm trying to get id values in parent and type values in child in qtree widget.
Please anyone help me with code and example.@Steve07
People seem to be asking the same question. Is your situation the same as that answered by https://forum.qt.io/topic/141394/how-to-fetch-muliple-children-inside-a-parents-which-belongs-to-same-parent-in-treewidget/2 ?Assuming you mean you want a separate child for each item in the "type values" (do you?), just add one node for each line/row/id and add a separate child for each item in the "type list". Very straightforward.
-
I'm having json format like this.
Json:
[
{ "id": "5001", "type": ["none"] },
{ "id": "5002", "type": ["glazed", "sugar"]},
{ "id": "5003", "type": ["glazed", "chocolate", "sugar"] },
{ "id": "5004", "type": ["powdered sugar", "chocolate", "sugar"] },
{ "id": "5004", "type": ["chocolate with sprinkles", "maple"]},
{ "id": "5005", "type": [" None", "chocolate", "glazed", "sugar", "powdered sugar"] }
]I'm trying to get id values in parent and type values in child in qtree widget.
Please anyone help me with code and example. -
@Steve07
People seem to be asking the same question. Is your situation the same as that answered by https://forum.qt.io/topic/141394/how-to-fetch-muliple-children-inside-a-parents-which-belongs-to-same-parent-in-treewidget/2 ?Assuming you mean you want a separate child for each item in the "type values" (do you?), just add one node for each line/row/id and add a separate child for each item in the "type list". Very straightforward.
-
@JonB yes. That was a similar one.
I haven't studied Qmap yet. So I'll try this after studying@Steve07
Yours may be slightly different. You only have one occurrence of a given parent, in the data you show. Therefore you would not have the issue of needing to recognise a duplicate row/id, to re-use as the parent to another row, which was the point of a map. Yours looks even simpler.