PDA

View Full Version : QTreeView: make root decoration appear on visual column 0



chezifresh
21st November 2008, 23:49
This is something thats always bothered me about the hierarchical views.

If you have view.setRootIsDecorated(true) set, the hierarchy of the model is represented by indenting the first column and adding dashed lines (like in all tree views).

The problem occurs when you re-order the columns. If you move the very first column over it still displays the root decoration (even though it's no longer the column farthest to the left). I'd like it so that whichever column is displayed as the first column shows the root decoration/indentation.

How can I go about doing this?

Is this because its using the logical index instead of the visual index? Or is there a decoration role I can change in my model to do this?

Thanks,

Matt

chezifresh
22nd November 2008, 02:36
I looked at the Qt source and it hard codes the root decoration to logicalIndex 0 meaning you would have to customize your model to be able to re-order the logical indicies of the header data.

so view.model().headerData(0) is always going to show the root decoration.