After changing column order, cannot select whole row
-
Give a simple example, a table with column A,B,C. In the QTableView I want the displaying order is A,C,B. I used following code:
@
QHeaderView* header=ui->tableView->horizontalHeader();
header->moveSection(2,1);
@After that, I cannot select whole row by click the left vertical header. If comment out above code, I can select row.
How can I get both features, need help. -
Hi,
Sounds like a strange behavior, can you provide a minimal example that reproduce the problem ?
-
A simple test example. F20 table has 3 columns: orgid, dptno, dptname. In tableview, I need hide orgid, and switch dptno and dptname.
If both of 'setColumnHidden' and 'moveSection' are in effect, I cannot select row, no whole row selection signal emitted. If comment any of them, it works.
@
void DlgScaleSetup::LoadDpt(int orgid)
{
QSqlTableModel* modelDpt=(QSqlTableModel*)ui->tableView_dpt->model();
if(modelDpt==0)
modelDpt=new QSqlTableModel(this);modelDpt->setTable("F20"); modelDpt->setFilter(QString("F20.orgid=%1").arg(orgid)); modelDpt->setEditStrategy(QSqlTableModel::OnManualSubmit); modelDpt->setHeaderData(0,Qt::Horizontal,tr("Organization"),Qt::EditRole); modelDpt->setHeaderData(1,Qt::Horizontal,tr("Dpt No"),Qt::EditRole); modelDpt->setHeaderData(2,Qt::Horizontal,tr("Dpt Name"),Qt::EditRole); modelDpt->select(); ui->tableView_dpt->setModel(modelDpt); ui->tableView_dpt->resizeRowsToContents(); ui->tableView_dpt->setColumnHidden(0,true); QHeaderView* header=ui->tableView_dpt->horizontalHeader(); header->moveSection(2,1);
}
@ -
Which version of Qt are you using ?