Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Json parsing into qtreewidget

Json parsing into qtreewidget

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.2k Views 2 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.
  • S Offline
    S Offline
    Steve07
    wrote on last edited by
    #1

    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.

    JonBJ M 2 Replies Last reply
    0
    • S Steve07

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

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

      S 1 Reply Last reply
      1
      • S Steve07

        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.

        M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3

        @Steve07

        Follow this example:
        https://www.bogotobogo.com/Qt/Qt5_QTreeWidget.php

        It's dam easy :)

        1 Reply Last reply
        1
        • JonBJ JonB

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

          S Offline
          S Offline
          Steve07
          wrote on last edited by
          #4

          @JonB yes. That was a similar one.
          I haven't studied Qmap yet. So I'll try this after studying

          JonBJ 1 Reply Last reply
          0
          • S Steve07

            @JonB yes. That was a similar one.
            I haven't studied Qmap yet. So I'll try this after studying

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

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

            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