我想将我的程序分成 3 个 QML 文件:一个 QML 文件包含数据模型 ( XMLlistModel
),另一个包含视图 ( ListView
),第三个用于启动程序。
import QtQuick 1.0
Item {
width: 800
height: 480
XmlListModel {
id: forecastModel
source: "http://www.google.com/ig/api?weather=&hl=fr"
query: "/xml_api_reply/weather/forecast_information"
XmlRole { name: "city"; query: "city/@data/string()" }
}
ListView {
x: 145; y: 325; width: 594; height: 48;
model: forecastModel
delegate: Text {
font.family: "Univers LT Std"; color: "#c8c8c8"; width: parent.width; font.pixelSize: 30
text: city
anchors.centerIn: parent.centerIn
}
}
}