This problem has nothing to do with the view.
If you do not want to insert the row at the front of the model rows then do not call insertRow(0,...). You want to insert the new row before the (non-existent) row rowCount():
Qt Code:
model->insertRow(model->rowCount(parentIndex), parentIndex);To copy to clipboard, switch view to plain text mode
There are other problems:
- Your thread title implies you are expecting a table structure but you appear to be trying to build a tree.
- You also set the text on the-most top-level item every time; not the item you just inserted.
- Have you called insertColumn() or setColumnCount() at some stage? Otherwise your model has no columns.
I think, in general, you need to read the QStandardItemModel Detailed Description for examples of creating a table.
Bookmarks