PDA

View Full Version : QTreeView with multiple models



Daher
16th April 2008, 18:36
Hello,

I have three models getting a tree of objects from three different databases. The interface designer is suggesting that we collect the 3 trees into subtrees in one page instead of having 3 pages for each set of data.

the only choice i can see right now is to setup a 4th model which will use every model for its own subtree, but this seems too harsh to implement. I was wondering if someone can give me a hint about a simpler solution.

Thanks in advanced.

aamer4yu
16th April 2008, 19:22
cant u make the 3 database info as one node of the tree

Something like -
Root
+ DB 1
+ DB 2
+ DB 3

where each of the branches can be expanded acc to the databases ???

wysota
16th April 2008, 19:37
the only choice i can see right now is to setup a 4th model which will use every model for its own subtree, but this seems too harsh to implement. I was wondering if someone can give me a hint about a simpler solution.

The simplest idea I can think of is to implement a simple proxy model that will add three fake top-level items and serve their children from real models. Shouldn't be more than 30 lines of code...

Daher
18th April 2008, 13:59
I'm facing a problem

in mapFromSource() the parameter 'index', i don't seem to be able to identify which source it is from. so that when i mapToSource() i will send it back to the correct source.

wysota
18th April 2008, 15:24
You have three models so reimplementing mapFromSource() is not enough.

papillon
18th October 2011, 10:53
The simplest idea I can think of is to implement a simple proxy model that will add three fake top-level items and serve their children from real models. Shouldn't be more than 30 lines of code...

It would be cool to get more detail on this topic...