PDA

View Full Version : QTreeView -- Alternating Row Colors Oddity



chuckshaw
4th October 2007, 00:20
I have a QTreeView displaying data from a custom model. Basically i turn on alternating row colors to make everything readable. However the alternating row colors do not paint all colums, only columns with data or where a model item has been created. Is there anyway to get that to paint across all columns regardless? In large trees its really distracting and ugly. This screen shot is using Qt 4.3.2 and QSA 1.2.2 btw.

Thanks,
Chuck

wysota
4th October 2007, 10:58
Are you sure each level of the model has the same number of columns? If you use QStandardItemModel it is important to call setColumnCount() with the same value for each level. For a custom model your columnCount() should return the same value for each index.

chuckshaw
4th October 2007, 19:41
That was it. I reimplemented columnCount() in my custom model to return the same column count for all indexes like you suggested and it now correctly paints across the treeview.

Thanks,
Chuck
:D