PDA

View Full Version : Not showing all of model columns in the view



nimaweb
7th August 2009, 19:40
It's my first post here, so be gentle if you think my question is ignorant. I'm new to the model/view concept.
I've got a 8-column model and I want my view just to represent SOME of its columns not all of them. In addition, these columns are not necessarily adjacent.
How should I do that? Shall I subclass QTableView and change its behavior? Shall I modify my model? I don't think it's got anything to do with my delegate.

franz
7th August 2009, 20:16
The best way to achieve that is to create a QSortFilterProxyModel. You don't have to change the behaviour of the view, you just have to filter out a bit of data.

remdex
7th August 2009, 20:16
Hi,

Quick answer. If you want remove some columns just.


ui.ClientTableView->setColumnHidden(4,true);
ui.ClientTableView->setColumnHidden(5,true);
ui.ClientTableView->setColumnHidden(6,true);

And if you want to set custom headers


clientsmodel->setHeaderData(20, Qt::Horizontal, tr("Deadline"));
clientsmodel->setHeaderData(21, Qt::Horizontal, tr("Finished"));
clientsmodel->setHeaderData(22, Qt::Horizontal, tr("Budget"));


All numbers in examples are column number.

nimaweb
7th August 2009, 20:31
Problemo Solved :)
Thanks, but do you think if I could place the columns in the view in order other than the corresponding ones in the model (or another view which has the same model)?

nimaweb
7th August 2009, 21:09
Problemo Solved :)
Thanks, but do you think if I could place the columns in the view in order other than the corresponding ones in the model (or another view which has the same model)?

I think I should do it like this:

personnelView.horizontalHeader().moveSection(1,4)
^ using PyQt