PDA

View Full Version : different model element, different delegate in a list view



huluyige
14th February 2011, 15:08
Hi everyone:

i would like create a listview (qml), where each element is not the same. Plus, the way to display each element (delegate) is not the same either.

is there anyone who have encounted this kind of problem?

thanks

chetu1984
17th February 2011, 21:10
Hi,
Even i have the same problem , checking for a solution . Hope someone would help us find a solution.

wysota
17th February 2011, 22:14
What do you mean by "not the same"?

huluyige
18th February 2011, 13:33
Hi,
Even i have the same problem , checking for a solution . Hope someone would help us find a solution.
hi
I have found the solution. you can use visualistmodel instead of listmodel.

huluyige
22nd February 2011, 10:38
What do you mean by "not the same"?
thanks for your reply,

for instance, if i use listmodel, but for each element, roles are not the same. how can i do it

wysota
22nd February 2011, 10:46
Roles are always the same. Their values might not be. If roles are different then you have two separate models. You can declare the delegate in such a way that it takes values into consideration.

huluyige
22nd February 2011, 11:45
Roles are always the same. Their values might not be. If roles are different then you have two separate models. You can declare the delegate in such a way that it takes values into consideration.

yes, that's the problem. if roles are not the same, what should i do? i think i can't use listmodel anymore.

wysota
22nd February 2011, 12:10
I really don't see your point. A model has to be consistent. Keeping "apples" and "cars" in a single model doesn't make any sense if they don't have anything in common. If they do (e.g. they are "objects") then they have the same roles (i.e. "object name", "object type", etc.). Then you can say if "object type" is "car", display it like this, otherwise display it like that.

wladek
4th March 2011, 13:46
Hi wysota,

You said
if "object type" is "car", display it like this, otherwise display it like that..
How exactly can you embed this "if" condition into the delegate?

Thanks in advance,
Wladek

huluyige
8th March 2011, 09:35
Hi wysota,

You said.
How exactly can you embed this "if" condition into the delegate?

Thanks in advance,
Wladek

you can use ? :