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. XmlListModel no Get()
Qt 6.11 is out! See what's new in the release blog

XmlListModel no Get()

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 541 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.
  • D Offline
    D Offline
    danilo_jn
    wrote on last edited by danilo_jn
    #1

    Hi everyone.

    So I've successfully created a model using the XmlListModel everything is working as intended. Before I was using a regular ListModel and writing all my data directly in QML. With the list model I could do something like :

    listModel.get(i).name

    How would I do this with an XmlListModel? Here's the model I am using as an example.

    XmlListModel {

        id: xmlModel
        source: "file:data/carousel_objects.xml"
        query: "/objects/item"
        XmlListModelRole {name: "title"; elementName: "title"}
        XmlListModelRole {name: "year"; elementName: "year"}
        XmlListModelRole {name: "sourceForeground"; elementName: "sourceForeground"}
        XmlListModelRole {name: "sourceBackground"; elementName: "sourceBackground"}
    
    }
    

    Thank you all in advance.

    Edit: I'm using Qt 6.6

    B 1 Reply Last reply
    0
    • D danilo_jn

      Hi everyone.

      So I've successfully created a model using the XmlListModel everything is working as intended. Before I was using a regular ListModel and writing all my data directly in QML. With the list model I could do something like :

      listModel.get(i).name

      How would I do this with an XmlListModel? Here's the model I am using as an example.

      XmlListModel {

          id: xmlModel
          source: "file:data/carousel_objects.xml"
          query: "/objects/item"
          XmlListModelRole {name: "title"; elementName: "title"}
          XmlListModelRole {name: "year"; elementName: "year"}
          XmlListModelRole {name: "sourceForeground"; elementName: "sourceForeground"}
          XmlListModelRole {name: "sourceBackground"; elementName: "sourceBackground"}
      
      }
      

      Thank you all in advance.

      Edit: I'm using Qt 6.6

      B Offline
      B Offline
      Bob64
      wrote on last edited by Bob64
      #2

      @danilo_jn This previous discussion might help. It suggests a workaround.

      https://forum.qt.io/topic/135419/get-method-removed-from-xmllistmodel

      D 1 Reply Last reply
      0
      • B Bob64

        @danilo_jn This previous discussion might help. It suggests a workaround.

        https://forum.qt.io/topic/135419/get-method-removed-from-xmllistmodel

        D Offline
        D Offline
        danilo_jn
        wrote on last edited by
        #3

        @Bob64 Thanks a lot mate works like a charm.

        1 Reply Last reply
        0
        • D danilo_jn has marked this topic as solved on

        • Login

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