QML 应用程序中只有一行 ListView 填充,知道为什么吗?
我正在尝试创建一个简单的 QML 应用程序,它将获取我的活跃国际象棋游戏的 RSS 提要并用它做一些事情。此时,我只是尝试使用提要内容填充列表视图,但即使提要中应该有 11 个项目,它也只显示一项。这是一个错误还是我没有得到正确的东西?
代码如下:
import Qt 4.7
import "content"
Rectangle {
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 }
}
}
}
委托应该没问题,因为我注释掉的简单委托也会发生同样的事情。
I'm trying to create a simple QML application that will get an RSS feed with my active chess games and do stuff with it. At this point I am just trying to populate a list view with the feed contents, but it only shows one item even when there should be 11 items in the feed. Is this a bug or am I not getting something right?
Here's the code:
import Qt 4.7
import "content"
Rectangle {
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 all right, because the same thing also happens with the simple delegate I have commented out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的模型和视图都很好,是你的布局错误。尝试将
anchors.fill:parent
添加到 mainContainer 中。这应该解决它:Your model and view are fine, it's your layout that's wrong. Try adding
anchors.fill: parent
to mainContainer. That should fix it: