[Development] Programmable delegate selection for QML views
Svenn-Arne Dragly
svenn-arne.dragly at qt.io
Tue Aug 7 10:11:55 CEST 2018
On 08/06/2018 05:03 PM, Mitch Curtis wrote:
>> -----Original Message-----
>> From: gr3cko at gmail.com <gr3cko at gmail.com> On Behalf Of Pierre-Yves
>>
>>
>> A default delegate looks like the sensible way to go indeed.
>> But should we REQUIRE one ? Why can't we just not instantiate something
>> when no fitting delegate is found ? That's what I believe #1 is actually doing.
> It's an interesting question. :D Personally I don't see the point. The behaviour for views has always been that there will always be a delegate available when it is needed. How would "missing" delegates work? I would imagine that would mess up something, somewhere internally in Qt Quick view classes.
>
> Or to ask it a different way: why do you have data in your model if it shouldn't be displayed?
Sounds like it would be useful to filter data in a view. For instance,
if you have multiple views of the same data, but want only certain data
categories in each view. This could also be used to create dynamic
filters with a custom delegate chooser.
That being said, we already have existing and powerful mechanisms to
filter data in Qt, and I'm not sure if adding yet another mechanism to
choose from is a good idea.
However, I see many users setting the "visible" property of their
delegates based on some logic as a hacky filter implementation today
(just search for "how to filter data in QML"). This is typically because
subclassing QSortFilterProxyModel is too much hassle for a simple list,
for instance if all you need is a ListModel with 50 items and a search
box. I don't have a complete overview of models/views in QML, so please
correct me if there are other simple, yet more elegant ways of filtering
in these simple cases. Otherwise, this might be worth keeping in mind in
this discussion.
Svenn-Arne
More information about the Development
mailing list