Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 16
Registered: ‎12-16-2010
My Device: Not Specified
Accepted Solution

call page slot function from listItem

[ Edited ]


- I have a button inside a Custom ListItemComponent(caritem) and when I click it I want to call a slot function from the page that contains the list(carsListPage)



CODE
- the CustomListItem contains a button that trigger the signal named  itemchangePicture

Page {
    id: carsListPage

    Container {
        
        ListView {
            id: carsList
            dataModel: carsModel

            listItemComponents: [
                ListItemComponent {
                    id:listItem
                    type: "item"
                    CustomListItem { //contains a signal called itemchangePicture
                         id:carItem   
                            onCreationCompleted: {
                            
           carItem.itemchangePicture.connect(carsListPage.changePicture); //this doewn't work cannot  find carsListPage
    }}}

    // Slot  function to change picture for carsListPage
    function changePicture() {
      //change the picture  
    }
         
}// Page

 

Thanks

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: call page slot function from listItem

In the docs for ListView, carefully read the section starting at "List visuals in QML", especially the parts about ListItem.view and the surrounding stuff.

 

Basically you have to do what you're doing indirectly through a property on the ListView and access via ListItem.view, or similar approaches.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
Posts: 16
Registered: ‎12-16-2010
My Device: Not Specified

Re: call page slot function from listItem

carItem.ListItem.view.changePicture() works . THANKS