Reputation: 91
Below is a snippet of my code in which I get the error above.days
is nested model:
ApplicationWindow {
id:appWindow
width: 1000
height: 600
visible:true
flags:Qt.FramelessWindowHint
//color: "transparent"
property var monthName:0
property string notesText: monthlistModel.get(monthofdayCalendar.currentIndex).days.get(newdayCalendar.currentIndex).hours.get(dayList.currentIndex).notes
Settings {
property alias notesText: appWindow.notesText
}
Below is the listmodel
with nested models:
ListModel{
id:monthlistModel
Component.onCompleted: {
let months = [
{
monthName: 0,
days: createDays(31)
},
{
monthName: 1,
days: createDays(29)
},
{
monthName:2,
days: createDays(31)
},
{
monthName: 3,
days: createDays(30)
},
{
monthName:4,
days: createDays(31)
},
{
monthName: 5,
days: createDays(30)
},
{
monthName: 6,
days: createDays(31)
},
{
monthName: 7,
days: createDays(31)
},
{
monthName:8,
days: createDays(30)
},
{
monthName: 9,
days: createDays(31)
},
{
monthName: 10,
days: createDays(30)
},
{
monthName: 11,
days: createDays(31)
}
]
append(months)
}
function createDays(dayCount) {
let days = []
for (let i = 0; i < dayCount+1; i++) {
days.push({
day: i ,
hours: createHours()
}
)
}
return days
}
function createHours() {
let hours = []
for (let i = 0; i < 25; i++) {
hours.push({
hour: i,
notes: ""
}
)
}
return hours
}
}
The application code is in below link
https://gist.github.com/cgiannakidis70/a5f0f73440013424fc0dedd7e3300f75
How to solve the above error?
Thanks in advance.
Upvotes: -1
Views: 585
Reputation: 404
This is in heavy need of some refactoring in general.
That point aside, your ListModel should contain ListElements, not javascript objects and nested arrays. Might be worth a good readthrough on the ListModel documentation. Here's a somewhat-related question to help out a little more.
Upvotes: 0