[Qt-qml] List Elements with references to Items

Martin Jones martin.jones at nokia.com
Tue Jul 27 01:13:49 CEST 2010


On Mon, 26 Jul 2010 06:08:22 pm Westbrook Alan (Nokia-MS/MtView) wrote:
> Hi,
> 
> I have need to reference an item (for dynamic creation of an object) and a
> model (for that items contents) from a ListElement.
> 
> When I try and add a property that isn't a basic QML type, it tells me 'no
> way Jose'.

ListModels populated by QML only support simple constants.

> Is there a recommended way of doing something like this?

You could populate the list dynamically in a Component.onCompleted handler for 
example.

Component.onCompleted: {
    filteritems.append( {"name": "location", "selected": false, "model": 
locations, "delegate": locationPref } )
}


>     Component {
> 
>         id: locationPref
> 
>         RadioGroup {
> 
>         }
> 
>     }
> 
> 
>     ListModel {
> 
>         id: locations
> 
>         ListElement { name: "home" }
> 
>         ListElement { name: "mars" }
> 
>         ListElement { name: "europe" }
> 
>         ListElement { name: "next door" }
> 
>     }
> 
> 
>     ListModel {
> 
>         id: filteritems
> 
>         ListElement { name: "location"; selected: false; model: locations;
> delegate: locationPref }
> 
>     }
> 
> Again, apologies for the colors.
> 
> Alan

-- 
Martin



More information about the Qt-qml mailing list