Search code examples
blackberryblackberry-10blackberry-cascades

how to access qml ContextProperty variable in ListItemComponent of ListView


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


Solution

  • 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);
                }
    
    
    }