PDA

View Full Version : Using a single model for views that show different column data



philwinder
23rd November 2008, 11:45
Hi,
here's what I want to do. I have a model which is used in a tree view, but what I want to do is to have different tree views that show different columns.

For example, the model contains all the data that I want (e.g. Name, Address, Type, Temperature, Light), and I want the first view to only show Name, Address and Type. Then I want the second view to show Name, Temperature and Light. (Almost poetic!)

I thought of passing a "View Type" parameter to the models constructor so that it only generates columns appropriate to that view but I'm sure there is a more elegent way to do it. Any idea's how?

caduel
23rd November 2008, 14:11
You can use QSortFilterProxyModel: create one proxy for each treeview and filter out unwanted columns.

Or you can operate on the view level: QTreeView::hideColumn()

HTH