I'm trying to unittest my implementation of QAbstractTableModel. I have implemented rowCount(), columnCount() and data() methods.
After instantiating my model, no matter how many nestings deep, the parent index is always invalid:
parent = model->index(0, 0);
i = model->index(0, 0, parent); // i.parent().IsValid() == false!
Now, i is valid. But i.parent() is not. Even if I do further nesting:
ancestor = model->index(0, 0);
parent = model->index(0, 0, ancestor);
i = model->index(0, 0, parent); // i.parent().IsValid() == false!
even then, i is valid but i.parent() is not.
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.
Why is my parent index always invalid?
is parent? - Dillydill123QAbstractItemModelnotQAbstractTableModel- RobbieE