[Qt-interest] How to just show tree model _leaf nodes_ in a table view?
Andre Somers
andre at familiesomers.nl
Mon Apr 4 11:17:35 CEST 2011
Op 4-4-2011 10:53, Patricia Santana Cruz schreef:
> Hello everybody,
>
> I have a tree model that I am using as the master model, and two proxy
> models (a tree proxy model and a table proxy model) that set this master
> model as their source model. On the other hand I have a tree view using
> the tree proxy model and a table view using the table proxy model (see
> attached picture).
>
> The structure of my tree looks like follows:
> --------
> | Root |
> --------
> |
> |__Year1
> | |
> | |__Week1
> | | |
> | | |__Day1
> | | |
> | | |_Task1
> | | |
> | | |_Task2
> | | |
> | | |_Task3
> | |
> | |__Week2
> | |
> | |__Day1
> | | |
> | | |_Task1
> | |
> | |__Day2
> |
> |__Year2
> |
> |__Week1
> |
> |__Day1
> |
> |_Task1
> |
> |_Task2
> |
> |_Task3
>
> As you see, all the leaf-nodes are tasks. I would like that every time I
> click an item in the tree view, all its _leaf nodes_ and just the _leaf
> nodes_ are displayed in the table view. Example:
> Click on Year1: Task1, Task2, Task3 and Task1.
> Click on Year1->Week1: Task1, Task2 and Task3.
> Click on Year1->Week2->Day1: Task1.
>
> Currently, I am connecting the 'clicked' signal on the tree view with
> 'setRootIndex()' on the table view, so I am getting the following
> results:
> Click on Year1: Week1 and Week2.
> Click on Year1->Week2: Day1 and Day2.
> Click on Year1->Week1->Day1: Task1, Task2 and Task3.
>
> How could I get just the _leaf nodes_ for all the other elements (year
> and week) as I explained?
>
> Thank you in advance,
> Patricia.
You are not telling us anything about your table proxy model. You can do
this with a proxy model, and it is in this table proxy model that this
should happen.
A little bit of googling already turned up useful code. I used the
keywords 'qt proxy flatten tree' in my search. I have found several
implementations you could use as a base for your implementation...
André
More information about the Qt-interest-old
mailing list