[Qt-qml] Extending with C++, basic QML list type question
Harri Pasanen
harri at mpaja.com
Tue Nov 22 10:03:15 CET 2011
On 11/22/2011 09:41 AM, bea.lam at nokia.com wrote:
> On 22/11/2011, at 6:15 PM, ext Harri Pasanen wrote:
>> Component.onCompleted: {
>> console.log("completed")
>> console.log(pie.slices)
>> console.log(pie.slices[1].color)
>> }
>> }
>>
>>
>> When I run chapter5-listproperties project with this, it spits out
>>
>> TypeError: Result of expression 'pie.slices[1]' [undefined] is not an object.
>>
>
> Ah, I see - in this case, the PieChart class needs to pass an AtFunction as well as a AppendFunction to the QDeclarativeListProperty constructor. The AtFunction will provide index-based access to objects within the list. In the BirthdayParty example, this functionality was added automatically, since the example used the convenience constructor of QDeclarativeListProperty.
Ok, makes sense. Thanks for the explanation.
/Harri
More information about the Qt-qml
mailing list