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. ListView section with QList<QObject*> as model not working

ListView section with QList<QObject*> as model not working

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 323 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.
  • Y Offline
    Y Offline
    yeehaw
    wrote on last edited by yeehaw
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      Test this out with a QML ListModel with the same QML. I don't think all properties on a QObject are automatically turned into properties the ListView delegate can see. Otherwise it would pollute the delegate namespace. To get the values out of the QObject you will have to use modelData.<property>. You could try that in section.property to see if that will work. "modelData" for a "list" used as a model is the property it injects.

      For a "proper" model you would need to base off of QAbstractListModel or similar. Then the properties you see are defined in roleNames function.

      Try this to see if this is what is happening (not sure if this would work though):

      section.property: "modelData.label"  
      

      Edit: I think I said something badly:
      When using a list of some sort (QList, [], etc) that is not based upon one of the abstract models. The injected delegate property is called "modelData". This would be each item from the list in that property. So in your case it would be the LandmarkViewModel object.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved