In my software I have a tableview with a model.
While runtime the model changes. Sometimes I want to hide columns, but after I changed the model a third time it does not work anymore.

Qt Code:
  1. void MonitorWindow::setColumnsHidden(bool hide){
  2. for (int i = 0; i < myTransducermodel->columnCount(); ++i){
  3. qDebug() << hide << i;
  4. ui->transducerTable->setColumnHidden(i, hide);
  5. qDebug() << "hidden?" << ui->transducerTable->isColumnHidden(i);
  6. }
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

The Debug says:
true 0
hidden? false
true 1
hidden? false
true 2
hidden? false
true 3
hidden? false
...

Why is that? Do I miss something when I set a new model?

Qt Code:
  1. myTransducermodel->clearColumns();
  2.  
  3. ....
  4.  
  5. ui->transducerTable->setModel(myTransducermodel);
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. void TransducerSetModel::clearColumns(){
  2. tableHeaders.clear();
  3. }
To copy to clipboard, switch view to plain text mode