Solved Problems with xml
-
I created an xml file that ill like to use in my qml but my model isn't getting populated.
This is my xml code<?xml version = "1.0"?> <rss version = "2.0"> <movieData> <data> <imageUrl>https://user-images.githubusercontent.com/2865368/26898832-3a492bb8-4b9b-11e7-8b51-ddf416424904.png </imageUrl> <name>Movie1</name> <date>Date1</date> <stars>*****</stars> </data> <data> <imageUrl>https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2017/11/autumn_fireball/17255671-1-eng-GB/Autumn_fireball.jpg </imageUrl> <name>Movie2</name> <date>Date2</date> <stars>***</stars> </data> <data> <imageUrl>http://wallpapersdsc.net/wp-content/uploads/2016/09/Melbourne-Images.jpg</imageUrl> <name>Movie3</name> <date>Date3</date> <stars>****</stars> </data> <data> <imageUrl>http://cdn.spacetelescope.org/archives/images/screen/opo9229a.jpg</imageUrl> <name>Movie4</name> <date>Date4</date> <stars>****</stars> </data> <data> <imageUrl>http://cdn.spacetelescope.org/archives/images/screen/heic1509d.jpg</imageUrl> <name>Movie5</name> <date>Date5</date> <stars>*****</stars> </data> </movieData> </rss>
This is my qml code
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.XmlListModel 2.12 Rectangle { visible: true width: 300 height: 480 id: root; color: "black" XmlListModel{ id: movieModel source: ".MovieData.xml" query: "/rss/movieData/data" XmlRole{name: "imageUrl"; query: "imageUrl/string(@url)"} XmlRole{name: "name"; query: "name/string()" } XmlRole{name: "date"; query: "date/string()"} XmlRole{name: "stars"; query: "stars/string()"} } Component{ id: itemDelegate Rectangle{ color:"black" border.color: Qt.lighter(color) Column{ id:column anchors.fill: parent Image{ id: image anchors.margins: 6 source: imageUrl fillMode: Image.PreserveAspectFit } Text{ id: title color:"white" x: image.x text:name } Text{ id: dateTitle color: "white" x:image.x text: date } Text { id: starsTitle color: "white" x: image.x text: stars } } } } ListView{ id: listView anchors.fill: parent model: movieModel delegate: itemDelegate } }
-
@Abdulmueez
I know nothing about this, but:source: ".MovieData.xml"
that is supposed to have that leading
.
, is it? It's not supposed to be./MovieData.xml
or anything else? -
@Abdulmueez
I know nothing about this, but:source: ".MovieData.xml"
that is supposed to have that leading
.
, is it? It's not supposed to be./MovieData.xml
or anything else? -
Thanks a lot, that solved the problem