0

プログラムを 3 つの QML ファイルに分割したいと考えています。データ モデルを含む 1 つの QML ファイル ( XMLlistModel)、ビューを含む別の QML ファイル ( ListView)、およびプログラムを起動する 3 つ目の QML ファイルです。

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
        }
    }
}
4

1 に答える 1

0

それは次のようなものになります

予測モデル.qml

XmlListModel {
    source: "http://www.google.com/ig/api?weather=&hl=fr"
    query: "/xml_api_reply/weather/forecast_information"
    XmlRole { name: "city"; query: "city/@data/string()" }
}

ForecastView.qml

ListView {
    x: 145; y: 325; width: 594; height: 48;
    delegate: Text {
        font.family: "Univers LT Std"; color: "#c8c8c8"; width: parent.width; font.pixelSize: 30
        text: city
        anchors.centerIn: parent.centerIn
    }
}

main.qml

import QtQuick 1.0

Item {    
    width: 800
    height: 480

    ForecastModel {
        id: forecastModel
    }

    ForecastView {
        model: forecastModel
    }
}
于 2011-06-23T23:50:19.147 に答える