title: QSqlTableModel, QTableView change columns not updated
body: <p>I have a SQL model that connects to a single table, this table will change the number of columns depending on certain conditions during the execution of the program. The model is connected to a QTableView.
  I have a function that controls the number of columns at the end of the function i have a call to model->select(), to update the information of the model and tableView->reset(), to what i thought would rearrange the view adding or taking away columns.
  The problem is that the view does not change from the original number of columns that it had. If i reduce the number i can see that the data change and show empty on the missing columns. Is there a command for the tableView to resize it self?
  Editing the question
  in the constructor of the class i'm reading the table and setting it to the view:</p>
  
  <pre><code>  header = new QSqlTableModel(parent,data-&gt;m_db);
    header-&gt;setTable("C"+QString::number(markTime.toSecsSinceEpoch())+"T");
    header-&gt;select();
    ui-&gt;heading-&gt;setModel(header);
    ui-&gt;heading-&gt;show();
  </code></pre>
  
  <p>Every time that that the number of columns is changed is an SQL procedure to change the number of columns:</p>
  
  <pre><code>void ImportProcess::copyTable(QString oldTable, QString newTable)
  {
    QSqlQuery queryOld, queryNew;
    queryOld.prepare("select * from :oldTable");
    queryOld.bindValue(":oldTable",oldTable);
    queryOld.exec();
  
    if(queryOld.record().isEmpty()==true) return; //Old table was empty, nothing to copy
  
    int oldColumn=queryOld.record().count();
  
    QString replaceLine="insert into "+newTable+" values(";
    while(queryOld.next()==true)
      {
        replaceLine.append(QString::number(queryOld.value(0).toInt()));
        replaceLine.append(", "+queryOld.value(1).toString());
        for(int y=0;y&lt;(oldColumn &lt; ui-&gt;columns-&gt;value() ? oldColumn : ui-&gt;columns-&gt;value());y++)
          {
            replaceLine.append(", "+QString::number(queryOld.value(y+2).toFloat()));
          }
        replaceLine.append(")");
        queryNew.exec(replaceLine);
      }
  }
  </code></pre>
  
  <p>Then the header file is updated, and here is where I thought that the tableview will be redrawn:</p>
  
  <pre><code>void ImportProcess::updateHeadingTable()
  {
    QSqlQuery query;
    query.exec("delete from C"+QString::number(markTime.toSecsSinceEpoch())+"T");
    QString description= ui-&gt;Week-&gt;isChecked() == true ? "Week" : "Size";
    query.exec("insert into C"+QString::number(markTime.toSecsSinceEpoch())+"T (id, description) values (101, '"+description+"')");
    for(int x=0;x&lt;ui-&gt;columns-&gt;value();x++)
      {
        query.exec("update C"+QString::number(markTime.toSecsSinceEpoch())+"T set col"+QString::number(x)+" = '30'");
      }
    header-&gt;select();
    ui-&gt;heading-&gt;reset();
  
  }
  </code></pre>