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 issue

XmlListModel issue

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 185 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.
  • xavi-bX Offline
    xavi-bX Offline
    xavi-b
    wrote on last edited by xavi-b
    #1

    Hi,

    I'm trying to display entries from the Google Contacts API XML data
    https://developers.google.com/contacts/v3#retrieving_all_contacts
    with the following code:

    import QtQuick 2.0
    import QtQuick.Controls 2.0
    import QtQuick.XmlListModel 2.0
    
    Item {
        width: 400
        height: 300
    
        ListView {
            id: listView
            anchors.fill: parent
            model: model
            delegate: Text {
                id: name
                text: qsTr("title: ") + title
            }
        }
    
        XmlListModel {
            id: model
            xml: "<feed"
                 +" xmlns=\"http://www.w3.org/2005/Atom\""
                 +" xmlns:openSearch=\"http://a9.com/-/spec/opensearch/1.1/\""
                 +" xmlns:gContact=\"http://schemas.google.com/contact/2008\""
                 +" xmlns:batch=\"http://schemas.google.com/gdata/batch\""
                 +" xmlns:gd=\"http://schemas.google.com/g/2005\""
                 +" gd:etag=\"feedEtag\">"
    
            +"<id>userEmail</id>"
            +"<updated>2008-12-10T10:04:15.446Z</updated>"
            +"<category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>"
            +"<link rel=\"http://schemas.google.com/g/2005#feed\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full\"/>"
            +"<link rel=\"http://schemas.google.com/g/2005#post\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full\"/>"
            +"<link rel=\"http://schemas.google.com/g/2005#batch\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full/batch\"/>"
            +"<link rel=\"self\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full?max-results=25\"/>"
            +"<author>"
            +"<name>User</name>"
            +"<email>userEmail</email>"
            +"</author>"
            +"<generator version=\"1.0\" uri=\"http://www.google.com/m8/feeds\">Contacts</generator>"
            +"<openSearch:totalResults>1</openSearch:totalResults>"
            +"<openSearch:startIndex>1</openSearch:startIndex>"
            +"<openSearch:itemsPerPage>25</openSearch:itemsPerPage>"
    
            +"<entry gd:etag=\"contactEtag\">"
            +"<id>http://www.google.com/m8/feeds/contacts/userEmail/base/contactId</id>"
            +"<updated>2008-12-10T04:45:03.331Z</updated>"
            +"<app:edited xmlns:app=\"http://www.w3.org/2007/app\">2008-12-10T04:45:03.331Z</app:edited>"
            +"<category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>"
            +"<title>Fitzwilliam Darcy</title>"
            +"<gd:name><gd:fullName>Fitzwilliam Darcy</gd:fullName></gd:name>"
            +"<link rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"https://www.google.com/m8/feeds/photos/media/userEmail/contactId\" gd:etag=\"photoEtag\"/>"
            +"<link rel=\"self\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full/contactId\"/>"
            +"<link rel=\"edit\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/userEmail/full/contactId\"/>"
            +"<gd:phoneNumber rel=\"http://schemas.google.com/g/2005#home\" primary=\"true\">456</gd:phoneNumber>"
            +"<gd:extendedProperty name=\"pet\" value=\"hamster\"/>"
            +"<gContact:groupMembershipInfo deleted=\"false\" href=\"http://www.google.com/m8/feeds/groups/userEmail/base/groupId\"/>"
            +"</entry>"
    
            +"<!-- Other entries ... -->"
    
            +"</feed>"
    
            query: "/feed/entry"
            XmlRole { name: "title"; query: "title/string()" }
    
            onStatusChanged: {
                if (status == XmlListModel.Null) {
                    console.log("Null");
                }
                if (status == XmlListModel.Ready) {
                    console.log("Ready");
                    console.log(count);
                }
                if (status == XmlListModel.Loading) {
                    console.log("Loading");
                }
                if (status == XmlListModel.Error) {
                    console.log("Error");
                    console.log(errorString());
                }
            }
        }
    }
    

    But is doesn't seem to work and no error is logged.

    Any help ? :)

    1 Reply Last reply
    0
    • xavi-bX Offline
      xavi-bX Offline
      xavi-b
      wrote on last edited by
      #2

      Answer here:
      https://stackoverflow.com/questions/59869179/xmllistmodel-issue-when-fetching-from-the-google-contacts-api-xml

      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