PDA

View Full Version : How to implement a list with varying column headers with a QTreeVieew in Qt4



manni66
11th January 2011, 12:58
I am trying to build a windows explorer like application with Qt4. On the left side there is a tree, the right side contains a list. The list uses a QTreeView to display the columns. My problem are the column headings: depending on the selected node in the tree there are distinct column headers in the list. Since QAbstractItemModel::headerData has no dependency on a QModelIndex (like columnCount), my solution was to let headerData return the union of all possible column headers and to hide the ones that are not needed for the current node( with a class derived from QHeaderView). There remains on problem: the sequence of columns is the same for all nodes (I can’t have “Name|Color|Size” for one node and “Color|Name|Date” for another). Has anybody implemented something like that and knows a solution?

tbscope
11th January 2011, 13:04
A filter or delegate would problably work.
You might want to create some user defined data (user roles) that let the delegate (for example) know how to arange the columns.

manni66
11th January 2011, 13:15
A filter or delegate would problably work.
You might want to create some user defined data (user roles) that let the delegate (for example) know how to arange the columns.

Can you elaborate on that?