PDA

View Full Version : Pivot Table with QTreeView: changing display properties on expanded rows



fede
18th April 2011, 02:21
Hello,

I am trying to implement a 'pivot table' in PyQt using a QTreeView. I have started from Mark Summerfeld's example 'Representing Tabular Data in Trees' and modified it so that it will calculate subtotals for numeric fields under each branch (and sub-branches).

The example works OK so far, but I would like to be able to change the view according to wether a given row is expanded or not. In particular, I would like to be able to hide or change the colours for the expanded rows' subtotals, or changing their background colour, etc, so that they do not distract (or at least are easily distinguishable from) the final nodes of the tree ('leaves') and the unexpanded subtotals. (Please check out the attached image and code).

My question is: where should I try to do this? I thought about creating a custom delegate, but I cannot grasp how the delegate could know wether a given row is is expanded or not in the view.

Thanks a lot,

Federico.
6242
6243