XmlListModel
-
I typed a sample, but it displayed nothing in tableView, Did I do anything wrong?
@import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0
import QtQuick.XmlListModel 2.0ApplicationWindow {
id: root
title: qsTr("L2 Tool")
width: 500
height: 360
TableView {
id: flickerTable
TableViewColumn {
title: "Column 1"
role: "title"
}
model: flickerModel
}XmlListModel{ id: flickerModel source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=Cat" query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "date"; query: "pubDate/string()" } XmlRole { name: "source"; query: "media:thumbnail/@url/string()" } XmlRole { name: "credit"; query: "media:credit/string()" } }
}@
!http://xiangce.baidu.com/picture/detail/ba52e93a7a2aaf584f66189f103f5b0762ca05dc(pic)! -
Seems ok, and I got it to work with adding visible = true for the ApplicationWindow and I also made the TableView cover the whole window with anchors.fill: parent.
@import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.XmlListModel 2.0ApplicationWindow {
id: root
title: qsTr("L2 Tool")
width: 500
height: 360
visible: trueTableView { id: flickerTable anchors.fill: parent TableViewColumn { title: "Column 1" role: "title" } model: flickerModel } XmlListModel{ id: flickerModel source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=Cat" query: "/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "date"; query: "pubDate/string()" } XmlRole { name: "source"; query: "media:thumbnail/@url/string()" } XmlRole { name: "credit"; query: "media:credit/string()" } }
}
@