title: Qt QTreeView not updating when adding to model
body: <p>The source code relating to this question is available on my <a href="https://bitbucket.org/josefvanniekerk/hid-descriptor-builder/src" rel="nofollow noreferrer">public Git repository on BitBucket</a>.</p>
  <p>I'm trying to dynamically add some items to a <code>QTreeView</code> model using the following code in <a href="https://bitbucket.org/josefvanniekerk/hid-descriptor-builder/src/c3985948ed098378246265434674c8c24718f2b5/mainwindow.cpp?at=master#cl-70" rel="nofollow noreferrer">mainwindow.cpp</a>:</p>
  <pre><code>if(dlg-&gt;exec() == QDialog::Accepted) {
      QList&lt;QVariant&gt; qList;
      qList &lt;&lt; item.name &lt;&lt; &quot;1111 0000&quot; &lt;&lt; &quot;0x00&quot;;
      HidDescriptorTreeItem *item1 = new HidDescriptorTreeItem(qList, hidDescriptorTreeModel-&gt;root());
      hidDescriptorTreeModel-&gt;root()-&gt;appendChild(item1);
  }
  </code></pre>
  <p>This works when run from within my <code>MainWindow</code> constructor, just after <a href="https://bitbucket.org/josefvanniekerk/hid-descriptor-builder/src/c3985948ed098378246265434674c8c24718f2b5/mainwindow.cpp?at=master#cl-5" rel="nofollow noreferrer"><code>ui-&gt;setupUi(this)</code></a>, but I need this to run from within an event filter, but the same code doesn't get the <code>QTreeView</code> updating. When I set a breakpoint at <code>mainwindow.cpp:70</code> and step through the next few lines, I can see the data is being added to the Model, but I need the <code>QTreeView</code> to refresh.</p>
  <p>I understand this is done by emitting <code>dataChanged()</code>, but not really sure how to do this. The signal signature for the <code>dataChanged</code> signal looks as follows:</p>
  <pre><code>void dataChanged(const QModelIndex &amp;topLeft, const QModelIndex &amp;bottomRight, const QVector&lt;int&gt; &amp;roles = QVector&lt;int&gt;());
  </code></pre>
  <p>so I need to come up with <code>topLeft</code> and <code>bottomRight</code> <code>QModelIndex</code> instances. How do I build/obtain these from <code>item1</code> in the above snippet?</p>
  <p>Also, where does <code>beginInsertRows()</code> and <code>endInsertRows()</code> come into view with this, should I be calling these functions?</p>