Only one line ListView is filled in the QML application, why?

I am trying to create a simple QML application that will use my active chess game to get an RSS feed and do something with it. At this time I am just trying to use the feed content to fill List view, but it only shows one item, even though there should be 11 items in the feed. Is this a mistake or I didn’t get the correct answer?

This is the code:

import Qt 4.7
import "content"

Rectangle {< br /> id: window;
width: 320
height: 480

XmlListModel {
id: xmlModel

source: "http ://gameknot.com/rss.pl?n=kEzvYvEgfHoOmzQzQlY/5w5ITO5YDN"
query: "/rss/channel/item"

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

Column
{
id: mainContainer

ListView
{

id: list
model: xmlModel
delegate: ListDelegate {}
//delegate: Text {text: title }
}
}
}

The delegate should be correct, because the simple delegate I have commented out will also happen the same Thing.

Your model and view are very good, this is your layout is wrong. Try adding anchors.fill: parent to mainContainer. That should solve it:

Column
{
anchors.fill: parent
id: mainContainer

ListView
{
width: parent.width
height: parent.height

id: list
model: xmlModel
delegate: ListDelegate {}
//delegate: Text {text: title }
}
}

I am trying to create a simple QML application which will use me An active chess game to get the RSS feed and do something with it. At this time I just try to populate the list view with the feed content, but it only shows one item, even though there should be 11 items in the feed. Is this an error or I don’t have Get the correct answer?

This is the code:

import Qt 4.7
import "content"

Rectangle {< br /> id: window;
width: 320
height: 480

XmlListModel {
id: xmlModel

source: "http ://gameknot.com/rss.pl?n=kEzvYvEgfHoOmzQzQlY/5w5ITO5YDN"
query: "/rss/channel/item"

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

Column
{
id: mainContainer

ListView
{

id: list
model: xmlModel
delegate: ListDelegate {}
//delegate: Text {text: title }
}
}
}

The delegate should be correct, because the simple delegate I have commented out will also happen the same Things.

Your model and view are very good, this is your The layout is wrong. Try adding anchors.fill: parent to mainContainer. That should solve it:

Column
{
anchors.fill : parent
id: mainContainer

ListView
{
width: parent.width
height: parent.height

id : list
model: xmlModel
delegate: ListDelegate {}
//delegate: Text {text: title }
}
}

Leave a Comment

Your email address will not be published.