Reputation: 1473
I have problem to access exposed qml context Property variable in ListItemComponent.
e.g
applicationUI class:
qml->setcontextProperty("activeFrame",mActiveFrame);
main.qml
ListView{
id:model
listItemComponents: [
ListItemComponent {
id: listComponent
type:"item"
customListItem{
// here,i want to update cover.
// but error occur ,ReferenceError: Can't find variable: activeFrame
onPlayerStarted:{
activeFrame.isPlaying(true)
}
onPlayerStopped:{
activeFrame.isPlaying(false)
}
}
}
]
}
thanks
Upvotes: 0
Views: 353
Reputation: 1473
I found a solution.
To use activeFrame in ListitemComponent, we have to make new function in listview and call from customListItem.
ListView{
id:model
listItemComponents: [
ListItemComponent {
id: listComponent
type:"item"
customListItem{
id:listItem
onPlayerStarted:{
listItem.ListItem.view.playingActiveFrame();
}
onPlayerStopped:{
listItem.ListItem.view.resetActiveFrame();
}
}
}
]
function playingActiveFrame(){
activeFrame.isPlaying(true);
}
function resetActiveFrame(){
activeFrame.isPlaying(false);
}
}
Upvotes: 1
Reputation: 5649
Haven't tested, but something like this should work.
ListView{
id:model
listItemComponents: [
ListItemComponent {
id: listComponent
type:"item"
customListItem{
id:listItem
onPlayerStarted:{
listItem.ListItem.view.activeFrame.isPlaying(true)
}
onPlayerStopped:{
listItem.ListItem.view.activeFrame.isPlaying(false)
}
}
}
]
}
Because:
For some odd reason the listItemComponents are outside of the normal code flow. But you can work around it. Give your listItemComponent a name/id. Then you can reference trough the the parent ListView. Source
Upvotes: 0