Important: Please read the Qt Code of Conduct -

[Solved]help for XmlListModel

  • I try to use XmlListModel for my GridView using Creator 2.2 on Windows XP. I am using Qt 4.7.3 library.

    My XML file - img.xml
    @<?xml version="1.0" encoding="utf-8"?>

    the XmlListModel file - MyModel
    @XmlListModel {
    source: "./img.xml"
    query: "/root/item"

    XmlRole { name: "title"; query: "title/string()" }
    XmlRole { name: "source"; query: "source/string()" }


    and main.qml:
    @import QtQuick 1.0
    import "models" as Models

    Rectangle {
    width: 360
    height: 360

    Models.MyModel { id: xmlModel }
    ListView {
        width: 640; height: 480
        model: xmlModel
        delegate: Text { text: title }


    When I run it, just blank page and no error show up. What is the problem?

  • Hi,

    1. Please check your XML file - you have first element (title) there closing as </name>
    2. try to put your xml file into the same folder first and use direct reference: source: "img.xml" in your XmlListView and try it out...

  • Thank you. It solved my problem.

    But I do not know how to set this as [sloved]

  • @kathy only add "Solved" to the title of this post

Log in to reply