Qt hide column in QTableView

后端 未结 1 1407
难免孤独
难免孤独 2020-12-31 02:28

I want to hide the ID column in the QtableView and i can\'t do that on my implementation. Can anyone help me?

void MainWindow::on_a         


        
相关标签:
1条回答
  • 2020-12-31 03:13

    You use ui->tableView->setColumnHidden(6, true);, but there is no column with index 6. You should write ui->tableView->setColumnHidden(5, true); instead, because ID column number is rather 5 than 6.

    UPDATE:

    You also need to hide column(s) after you set the model to the view, i.e:

    ui->tableView->setModel(model);
    ui->tableView->setColumnHidden(5, true);
    
    0 讨论(0)
提交回复
热议问题