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. JsonModel/XmlModel vs nested ListModels

JsonModel/XmlModel vs nested ListModels

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 111 Views
  • 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.
  • N Offline
    N Offline
    NYBL
    wrote on last edited by NYBL
    #1

    Hello!
    I have a deliberation, i have a nested json response that takes a very important place in my logic, thus it needs to be fully CRUDed plus some extra stuff, question is what model should i use?

    currently i am using a dynamiclly created QAbstractListModel with corresponding roles for each layer of the response and ListView's
    where each ListView posses the model for the next ListView layer.
    something like:

    ListView{id: rootListView
        model: rootModel
        delegate:
        Rectangle{
            Text{text: model.someRootModelData}
             ListView{id: 2ndLayerListView
                 model: 2ndLayerModel
                 delegate:    Rectangle{
                         Text{text: model.2ndLayerData}
             }
         }
    }
    

    This approach drawback's are:

    1. lots of models - waist of resources.
    2. harder to customize each model functionality
    3. harder to update models outside the views e.g from another json response
    4. I will need to keep track of how many models do i have and when to delete or create new models.

    Advantages are:

    1.if a certain level is changed if i emit layoutChanged not all of my views need to be updated.
    2. easier to maintain at the QmlLevel as i fetch data very trivially (model.somthing)
    3. In the long run will be easier to fetch more data from my server.
    4. CRUD is easy

    Another approach i thought of is to use somthing like JsonListModel or XmlModel though i have no experience with them
    and i thought that if i have everything in one model if layoutChanged is emitted this will cause everything to update which is not necessarily needed plus i think CRUD will be harder .

    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