PDA

View Full Version : single Qt model/view different trees



Bziur
20th March 2014, 23:23
So I basically want to achieve sth like this:



|view1
|- file1
| |- item1
| |- item2
|- file2
| |- item3
| |- item4
|+ file3
...

view2
|- item1
|- item2
|- group1
| |- item3
| |- group2
| |- item4
|- item5
...


with 1 model. Is it possible?

wysota
20th March 2014, 23:56
It depends whether "item1" from view1 and "item1" from view2 are supposed to be the same item or not. If yes then you need to go through an additional proxy model. If not then yes, it is possible directly by setting different root indexes in each view.

anda_skoa
21st March 2014, 10:27
The question is: why one model?

Cheers,
_

Bziur
21st March 2014, 13:06
It depends whether "item1" from view1 and "item1" from view2 are supposed to be the same item.
Yes pretty much they are. I'll have a dip into this proxy model, even though technically it's another model isn't it?


The question is: why one model?
Because I want them to be bound, so let's say I select a group of items in view2, and I want these items to be selected in view1 and the group to be selected in my custom QGraphicsView. I want to be able to hide these items using both of the views etc. So it seems to make most sense using model/view approach.

wysota
21st March 2014, 13:53
Yes pretty much they are. I'll have a dip into this proxy model, even though technically it's another model isn't it?
Yes, however there is only one set of data and one place where the data is managed.