title: QTableView not updating properly
body: <p>I am creating a small program that takes user input into a model and then shows that input in several views that take it through filters.</p>
  
  <p>When the user clicks the button that accepts the input, the program updates the amount of cells in the views and then resizes those cells as necessary so that they fit neatly in their area.</p>
  
  <p>My problem is that the cell resizing doesn't seem to work for one of the views for some reason (I tried looking for differences but couldn't find a reason for what I'm experiencing).</p>
  
  <p>I'm calling the cell resizing function in two places:</p>
  
  <ol>
  <li>dataChanged slot.</li>
  <li>resizeEvent slot.</li>
  </ol>
  
  <p>If the cell resize function gets called <strong>twice</strong> inside dataChanged, then the view <strong>does</strong> update, however this involves some calculations and ui access and obviously not supposed to happen.</p>
  
  <p>If I <strong>resize</strong> my window then the cells are resized properly.</p>
  
  <p>I suspect that I'm always one update behind - that the view doesn't paint until the new update starts getting calculated and then that new update is on hold until the next calculation (since resize happens a lot of times in succession it might just act the same as the button but is harder/impossible to notice).</p>
  
  <p>I have some dirty workarounds:</p>
  
  <ol>
  <li>As I mentioned, if I call my cell resize function again, the view updates properly.</li>
  <li>If I remove the second "if" in this next piece of code then everything works.</li>
  </ol>
  
  <p>I thought I'd save my computer some work by only processing when the entire input had been received. My thinking was that, although dataChanged is emitted for every single item I'm inserting, I only really need to update once it is all in:</p>
  
  <pre><code>void MainWindow::on_dataChanged()
  {
      static int left_to_insert = -1;
  
      if ( 0 &gt; left_to_insert )
      {
          left_to_insert = m_model.rowCount() - 1;
      }
  
      if ( 0 == left_to_insert )
      {
          ...
              m_matrix_proxy.resize_to_fit();
              adjust_matrix_cells_sizes();
      }
      --left_to_insert
  }
  </code></pre>
  
  <p>Is it bad to only process the last signal? Why?</p>
  
  <p>I tried calling <code>update()</code> and/or <code>repaint()</code> on both the matrix and the main window.</p>
  
  <p>I tried calling both of these on the viewport of the <code>QTableView</code> and tried calling them in succession from the matrix itself to the highest parent that didn't make my program crash. (ui->matrix->parentWidget()->parentWidget()...)</p>
  
  <p>I tried <code>qApp-&gt;processEvents()</code>.</p>
  
  <p>I even resorted to emitting a <code>resizeEvent</code>, but this is overkill IMO as it makes some calculations be performed again.</p>
  
  <p>Just in case it is somehow relevant: The data appears correctly. The only thing that's wrong is that the cells don't resize.</p>