The problem is that you derive from QStandardItemModel.
When its index() method is called, it will always return a null index because it is empty.
Derive from QAbstractTableModel instead, or QAbstractListModel if you want a list.
In a full implementation your addItem() method would have to signal that rows are being added, see beginInsertRows(), endInsertRows().
In your simple example it should still be OK, since you add both items before you set the model on the view.
Cheers.
_
Bookmarks