How to construct a QModelIndex with valid parent?
<p>I'm trying to unittest my implementation of QAbstractTableModel. I have implemented rowCount(), columnCount() and data() methods. </p>

<p>After instantiating my model, no matter how many nestings deep, the parent index is always invalid:</p>

<pre><code>parent = model-&gt;index(0, 0);
i = model-&gt;index(0, 0, parent); // i.parent().IsValid() == false!
</code></pre>

<p>Now, i is valid. But i.parent() is not.
Even if I do further nesting:</p>

<pre><code>ancestor = model-&gt;index(0, 0);
parent = model-&gt;index(0, 0, ancestor);
i = model-&gt;index(0, 0, parent); // i.parent().IsValid() == false!
</code></pre>

<p>even then, i is valid but i.parent() is not.</p>

<p>I have unit tested the rowCount and columnCount methods and I've asserted that the model is a tree model that has one row with, nested, two rows. Also, the column count is nonzero.</p>

<p>Why is my parent index always invalid?</p>