title: dynamically add data to QTableView
body: <p>I'm writing a simple <code>TableView</code> according to </p>
  
  <p><a href="http://harmattan-dev.nokia.com/docs/library/html/qt4/itemviews-addressbook.html" rel="nofollow noreferrer">http://harmattan-dev.nokia.com/docs/library/html/qt4/itemviews-addressbook.html</a></p>
  
  <pre><code>class MyModel : public QAbstractTableModel {
      Q_OBJECT
  public:
      QList&lt;QPair&lt;string, int&gt; &gt; data_;
  ....
  </code></pre>
  
  <p>How to add rows to the model dynamically? <code>data_.insert(..)</code> won't change the view, currently I write a function to append new row:</p>
  
  <pre><code>void my_append_data(const string&amp; first, int second) {
      int row = rowCount(QModelIndex());
      insertRow(row); // insert a empty row
      // fill the row
      setData(createIndex(row, 0), QVariant::fromValue&lt;string&gt;(first), Qt::EditRole);
      setData(createIndex(row, 1), QVariant::fromValue&lt;int&gt;(second), Qt::EditRole);
  }
  // usage
  model.my_append_data("11111", 111);
  model.my_append_data("22222", 222);
  </code></pre>
  
  <p>This seems inefficient cause the <code>setData</code> is called twice when append a row, because there're two columns, and there may be more columns in the future.</p>
  
  <p>Any better way to append rows?</p>
  
  <p>Thanks.</p>