QML ListView multiple delegates
-
Greetings Qt Devs,
I'm using a ListView. Is it possible to specify multiple delegates based on what the model item contains ?
For instance:
- if my item has a parameter containing "green" I specify a green Rectangle delegate item.
- If my item has a parameter containing "string" I specify a Text delegate item.
Thanks.
-
Hi bunjee,
Take a look at this: "http://cdumez.blogspot.com/2010/11/heterogeneous-list-model-in-qml.html":http://cdumez.blogspot.com/2010/11/heterogeneous-list-model-in-qml.html
I think this is what you are looking for.Regards,
wladek -
Thanks guys,
I thought about the "loading" condition. I guess the performance might hurt a bit.
Best current option is probably hiding / showing specific parts. Not the most elegant way.
Ideally I think this should be taken care of in C++. A multi delegate ListView could be a good idea to code.
-
Hi bunjee,
From my experience I can assure you that the "loading" condition is by far the better from performance point of view. I had a large delegate that defined all my widgets, and I did exactly as you said....hide/show specific parts. The interface suffered a "hung" effect, and after changing to the "Loader" it worked nicely.
You should try it yourself the both ways and see which one pleases you.
regards,
Wladek