title: How to make sure columns in QTableView are resized to the maximum
body: <p>I'm not sure how to ask this, so, feel free to ask for more information.</p>
  
  <p>It seems that <code>tableView-&gt;resizeColumnsToContents()</code> will only resize all the columns based on data in current view. Which means that if I have more data below (which is longer in terms of counts of words), those words will be wrapped down (if the <code>wordWrap</code> property is set to true).</p>
  
  <p>The weird thing is, if I scroll down to the bottom and refresh the data, <code>tableView</code> will resize those columns correctly. It seems as if <code>tableView</code> didn't know there are longer text below.</p>
  
  <p>So, my question is, how can I make sure those columns are resized to the max based on all of the data?</p>
  
  <p>My codes</p>
  
  <pre><code>QSqlTableModel *model = new QSqlTableModel;
  model-&gt;setTable("item");
  model-&gt;setEditStrategy(QSqlTableModel::OnManualSubmit);
  model-&gt;select();    
  tableResult-&gt;setModel(model);    
  tableResult-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);    
  tableResult-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);
  tableResult-&gt;setSelectionMode(QAbstractItemView::SingleSelection);    
  tableResult-&gt;resizeColumnsToContents();
  tableResult-&gt;resizeRowsToContents();
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>I've tried <code>tableResult-&gt;scrollToBottom()</code> and it will only resize based on items at the bottom. So, if there are longer words in the middle, those words will get wrapped.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>If anyone would like to understand what I'm talking about, just <strike><a href="http://www.pikopong.com/tmp/cekpo.zip" rel="noreferrer">download</a></strike> this example. You'll see that clicking the PushButton will generate a data that's not resized correctly.</p>
  
  <p><strong>Update 3</strong></p>
  
  <p>Possibly a bug: <a href="http://bugreports.qt-project.org/browse/QTBUG-9352" rel="noreferrer">https://bugreports.qt.io/browse/QTBUG-9352</a></p>