@mcosta
Thanks
Put your example
js object
var exemple = { "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.90
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.90
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.90
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.90
}]
}
}
main.qml
import QtQuick 1.1
import "./data_list.js" as Js
Rectangle {
id: mainwindow
width: 700
height: 360
property string fontName: "Arial"
ListModel{
id: model_l
ListElement {
category:"";
author :"";
title :"";
price :"";
}
}
ListView{
id: view_l
model: model_l
delegate: my_delegate
anchors.fill: parent
}
Component {
id: my_delegate
PageDele {
str_p_category: model.category
str_p_author : model.author
str_p_title : model.title
str_p_price : model.price
}
}
Component.onCompleted: {
model_l.append({ title: "1st title", category: "1st cathegory", author: "1st author" });
var menu = Js.exemple.store.book;
for (var i = 0; i < menu.length; i++ ) {
model_l.append(menu[i]);
}
model_l.append({ title: "last title", category: "last cathegory" });
}
}
PagaDele.qml
import QtQuick 1.1
Rectangle {
height: 20
property int marg: 5
property alias str_p_author: author.text
property alias str_p_category: category.text
property alias str_p_title: title.text
property alias str_p_price: price.text
Row{
Text {
id: author
font{
family: mainwindow.fontName
bold: true
pixelSize: 14
}
color: "black"
text: ""
anchors.left: parent.left
anchors.leftMargin: marg
}
Text {
id: category
font{
family: mainwindow.fontName
bold: true
pixelSize: 14
}
color: "black"
text: ""
anchors.left: category.right
anchors.leftMargin: marg + author.text.length
}
Text {
id: title
font{
family: mainwindow.fontName
bold: true
pixelSize: 14
}
color: "black"
text: ""
anchors.left: category.right
anchors.leftMargin: marg + category.text.length
}
Text {
id: price
font{
family: mainwindow.fontName
bold: true
pixelSize: 14
}
color: "black"
text: ""
anchors.left: title.right
anchors.leftMargin: marg + title.text.length
}
}
}