Martin Jones wrote:
> On Tue, 11 May 2010 03:48:20 am ext Stephen Kelly wrote:
>> Martin Jones wrote:
>> >> * Can't access the data of the current item in the view from outside
>> >> the delegate. Inside the implementation of a delegate, it is possible
>> >> to use model.customDataRole inside the implementation of a delegate,
>> >> but if in another element you want to get particular data for "the
>> >> current item selected in that view", it doesn't seem possible in QML.
>> >
>> > The current item is available via ListView::currentItem.
>>
>> The challenge is to access the custom data from a C++ model through its
>> data() method of the "current" item. Possibly putting the text of the
>> current item somewhere else in the ui etc. As an example, try to access
>> the display role of the current item in this QML model:
>
> The reason is that those are context properties internal to the delegate.
> If you want to expose some of the delegate's data you could bind them to a
> property:
>
> Component
> {
> id :myDelegate
> Row {
> property variant display : model.display
> Text { height : 20; text : "Something" }
> Text { height : 20; text : model.display }
> }
> }
>
So much for model/view separation :)
I'm not really trying to get the "context properties internal to the
delegate", I'm trying to get "context properties internal to the model".
To do that it looks like I need to make sure the delegate has aliases for
any custom role I might want to use to retrieve data.
What if I want to get the data in the n-th row of a c++ model, not just the
"current item"? Will that ever be possible?
All the best,
Steve.
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml