Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt5 XmlListModel nested data
Forum Updated to NodeBB v4.3 + New Features

Qt5 XmlListModel nested data

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.4k Views 1 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.
  • H Offline
    H Offline
    hailong
    wrote on last edited by
    #1

    I have an xml file and I want to load it with xmllistmodel. The data structure is similiar to the code below.

    @
    <itemA>
    <settings> </settings>
    <ItembArray>
    <itemB>
    <settings>
    </settings>
    ...
    <ItemC>
    ...
    </ItemC>
    <ItemC>
    ...
    </ItemC>
    </itemB>
    ...
    <itemB>

      ...
    <ItemC>
     ...
    </ItemC>
    <ItemC>
     ...
    </ItemC>
    

    </itemB>
    </ItembArray>
    </itemA>
    @

    because xmllistmodel can only work as list model, so I want to add 3 views, viewA, ViewB , ViewC, and for each view , there is an xmlListModel, eg. modelA -> viewA, modelB -> viewB, modelC -> viewC. 
    I can set the same source for ModelA, ModelB, ModelC and use different query to get the data, but I think this is slow , because I need to open this xml file for many times, (viewA with many ViewBs and ViewB with many ViewCs), 
    So I think may I use model like this
    

    @
    modelA{
    id: modelA
    source: test.xml
    role1: itemA/settings
    role2: itemA/ItembArray
    }

    modelB{
        xml: modelA.get(0).role2
        role1: itemB/settings
        role2: itemB/ItemC
    }
    

    @

    but I don't know how to get the xml source code with XmlRole, is my way correct?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hailong
      wrote on last edited by
      #2

      In other words, how can I get the original xml source code from XmlRole so I can set this as other model's xml property.

      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