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
oumaimaBlueWave
Posts: 8
Registered: ‎03-11-2014
My Device: dev alpha B
My Carrier: blackberry

signal/slot in qml

hello, i need to emit a signal from qml page to another?

 

i have the first page that is an item of a list view:

Container {
 id: settingsItem
 .
 .
     id: container
  .
  .
  .
  {
    
    Container {
    
        Label {
          id: itemlabel
          .
          .
          .
        }

        ToggleButton {
            id: togglBtn
            signal remberMechanged(bool rememberChecked);
            enabled: true
            onCheckedChanged: {
                console.log(checked)
                remberMechanged(checked)
               
            }
        }

    }

 and in the main page:

Page {
   
 ListView {
                      
            dataModel: currentdataModel

            listItemComponents: [
                ListItemComponent {
                    id: header
                    type: "header"
                   ...
                },
                ListItemComponent {
                    id: item
                    type: "item"
                    SettingsItem {
                         id: settingItem
                        ....                         
                    }
               }              
            ]

            onTriggered: {
                var selectedItem = dataModel.data(indexPath);
                if (selectedItem.clickEnabled) {
                    _settingsDelegate.onClickItem(selectedItem.itemSettingLabel)

                }
            }
}

 so waht i need is to save the togglebutton's state: i want to send a signal that notify the main page (contains the listView) that toglebutton state have been changed.
I didn't find the perfect way to get it . can somone help me ??

 

 

 

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: signal/slot in qml

This example may help you if you are using delegates...

 

http://supportforums.blackberry.com/t5/Native-Development-Knowledge/How-to-pass-data-to-and-from-a-Q...


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
strobejb
Posts: 267
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: signal/slot in qml

I would reorganise things a little so you have this:

 

Container {
   id: settingsItem
   signal rememberMeClicked(bool checked)

   ...
      ToggleButton {
         id: toggleBtn
         onCheckedChanged: rememberMeClicked(checked);
      }

}

 

ListView {
  
   listItemComponents: [
     ListItemComponent {
       id: item

       SettingsItem {
         onRememberMeClicked: {
           console.log(checked);

           item.ListItem.view.rememberTriggered(item, checked);
         }
       }
     }
   ]

   function rememberTriggered(listItem, checked) {
       // this is called whenever a list item its toggle button changes
   }

}

 

Please use plain text.