[Qt-qml] List Elements with references to Items

alan.westbrook at nokia.com alan.westbrook at nokia.com
Tue Jul 27 01:28:27 CEST 2010


Thank you.

There's clearly a lot I need to learn about the javascript runtime (or at least just get used to it).

Alan

On Jul 26, 2010, at 4:13 PM, Martin Jones wrote:

> 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