Hai, I'm unable to display data from xmllistmodel to main.qml?
Unsolved
QML and Qt Quick
-
main.qml
import QtQuick 2.0
import QtCharts 2.0
import QtQuick.XmlListModel 2.0
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQml.Models 2.15ApplicationWindow {
width: 1000
height: 1000
visible: true
title: qsTr("Model")ChartView { id: chartView title: "Driver Speeds, lap 1" anchors.fill: parent legend.alignment: Qt.AlignTop animationOptions:ChartView.AllAnimations antialiasing: true } XMLLIST{ id:list } Component { id: fruitDelegate Row { spacing: 10 Text { text: speedTrap } Text { text: driver } Text { text: speed } } } ListView { anchors.fill: parent model: list delegate: fruitDelegate }
}
xmllist.qml import QtQuick.XmlListModel 2.0 XmlListModel { // Hard-coded test data xml: "<results><row><speedTrap>0</speedTrap><driver>Fittipaldi</driver><speed>104.12</speed></row>" +"<row><speedTrap>0</speedTrap><driver>Stewart</driver><speed>106.12</speed></row>" +"<row><speedTrap>0</speedTrap><driver>Hunt</driver><speed>106.12</speed></row>" //![1] +"<row><speedTrap>1</speedTrap><driver>Fittipaldi</driver><speed>115.12</speed></row>" +"<row><speedTrap>1</speedTrap><driver>Stewart</driver><speed>114.12</speed></row>" +"<row><speedTrap>1</speedTrap><driver>Hunt</driver><speed>115.12</speed></row>" +"<row><speedTrap>2</speedTrap><driver>Hunt</driver><speed>165.23</speed></row>" +"<row><speedTrap>2</speedTrap><driver>Fittipaldi</driver><speed>175.23</speed></row>" +"<row><speedTrap>2</speedTrap><driver>Stewart</driver><speed>168.23</speed></row>" +"</results>" //![2] query: "/results/row" XmlRole { name: "speedTrap"; query: "speedTrap/string()" } XmlRole { name: "driver"; query: "driver/string()" } XmlRole { name: "speed"; query: "speed/string()" } }
-
@Joshika_Namani works for me:
I changed a couple of things:
- XMLLIST in main.qml -> XmlList
- Saved the 'xmllist.qml' as 'XmlList.qml'
- Got rid of the chart stuff.
-
Its working now, due to main.cpp it didn't work. Thanks a lot. can I place those speed values in lineseries chart instead of Listview can i take lineseries chart