PDA

View Full Version : QT Model View - parent Item different from child



mromanuk
9th March 2011, 16:55
I have a list of items of a custom type like this:

Provider1, Client1
Provider2, Client1
Provider3, Client2
...

this can be done with list model, but each one of this provider could also have some "items" like this:
Provider 1
item1, place, type, date
item2, place, type, date
...

Conforming a tree:
Provider
-> items
Provider 2
-> items
...

What do you think is the best way to implement the model?
Should I make just 1 type of Item (sublcassing QAbstractItemModel)?
Change the behavior (accepting corresponding attributes) depending on the hierarchy?

Thanks in advance

wysota
9th March 2011, 17:54
What's the problem exactly? If you have different kinds of elements then you have different kinds of elements :)

mromanuk
9th March 2011, 18:21
Yes :) I found your article about the the OpenGL model. Is what I need; I will implement my model with 1 item and represent the different attributes as roles.