Not showing all of model columns in the view
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.
Re: Not showing all of model columns in the view
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.
Re: Not showing all of model columns in the view
Hi,
Quick answer. If you want remove some columns just.
Code:
ui.ClientTableView->setColumnHidden(4,true);
ui.ClientTableView->setColumnHidden(5,true);
ui.ClientTableView->setColumnHidden(6,true);
And if you want to set custom headers
Code:
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.
Re: Not showing all of model columns in the view
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)?
Re: Not showing all of model columns in the view
Quote:
Originally Posted by
nimaweb
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:
Code:
personnelView.horizontalHeader().moveSection(1,4)
^ using PyQt