QTableView sorting with verticalHeader()
Hi,
I have problem that when i use QSortFilterProxyModel, QSqlTableModel, QTableView i tableView the verticalHeader also is soring so is treaded as column :-(
Code:
forumCModel->setTable("ForumCatalogs");
forumCModel->setHeaderData(ForumCatalog_Id, Qt::Horizontal, tr("id"));
forumCModel->setHeaderData(ForumCatalog_Title, Qt::Horizontal, tr("Title"));
forumCModel->setHeaderData(ForumCatalog_Url, Qt::Horizontal, tr("Url"));
forumCModel->setHeaderData(ForumCatalog_HtmlData, Qt::Horizontal, tr("HtmlData"));
MyProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
MyProxyModel->setSourceModel(forumCModel);
forumCModel->select();
ui->tableViewFCatalogs->setModel(MyProxyModel);
ui->tableViewFCatalogs->setSortingEnabled(true);
ui->tableViewFCatalogs->resizeColumnsToContents();
headerForumCModel = ui->tableViewFCatalogs->horizontalHeader();
headerForumCModel->setStretchLastSection(true);
headerForumCModel->setSortIndicator(1,Qt::AscendingOrder);
Does anyone can tell me how to lock verticalHeader?
Re: QTableView sorting with verticalHeader()
Where is your vertical header?
Your code says: headerForumCModel = ui->tableViewFCatalogs->horizontalHeader();
Re: QTableView sorting with verticalHeader()
I think the issue that lonik is describing is that when you use the horizontal header to sort your table on a given column the vertical header labels, which are the row (logical index) number, move with their row. The result is that the vertical header labels are not in order like you would see in, for example, Excel when your sort the data. I think the way around this might be a QHeaderView derivative that used the visual index of the row for the label rather than the logical index.
Re: QTableView sorting with verticalHeader()
Ok Chris, I see what he means now. I just set the header column titles with model->setHeaderData(n, Qt::Horizontal, "Col_Name")
If he can do that, no more problem, right?