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
Developer
Posts: 324
Registered: ‎03-10-2010
My Device: Bold 9780, DevAlpha
My Carrier: Vodafone CZ
Accepted Solution

Variable/Object visibility in ListViewItem????

                           ListView {
                                id: lvPlacesResult
                                visible: false
                                horizontalAlignment: HorizontalAlignment.Fill
                                verticalAlignment: VerticalAlignment.Bottom
                                preferredHeight: 958
                                dataModel: dataModelPlaces
                                listItemComponents: [
                                    ListItemComponent {
                                        type: "item"
                                        MyLvItem {
                                            title: ListItemData.PlaceName
                                            description: ListItemData.Address + ", " + ListItemData.City
                                            showproximity: true
                                            proximity: MathFunctions.makeKmString(ListItemData.Distance, appsettings.getValueFor("map/units", 1))
                                            rating: (ListItemData.AvgRating / 5)
                                        }
                                    }
                                ]
                                snapMode: SnapMode.LeadingEdge
                                
                            }

 

appsettings object does not seens in  ListItemComponent :: MyLvItem

 

What i've doing wrong?

Highlighted
Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: Variable/Object visibility in ListViewItem????

ListItemComponent has its own variable scope. You can access properties of the ListView by doing:

ListItem.view.propertyName

To access variables from the global namespace, you can use this hack:

main.qml {
onCreationCompleted: {
Qt.appsettings = appsettings;
}
}

...
ListItemComponent {
MyLVItem {
Qt.appsettings // use the Qt. prefix to access global namespace
}
}