the code does not present relativity between modList
and tableModel
. tableModel->item(index,0)
was valid before changing modList
, while tableModel->rowAt(index)
becomes invalid after modifying. There are a few possibilities:
Modifying modList
affects tableModel
, as @vahancho implies. This can be verified by commenting out the for loop or changing the order of lines. This can be lead by use modList
as the real data of tableModel
, for example, are you implementing a custom QTableModel by returning modList->at(i)
as QTableModel::Data
and returning modList->count()
as QTableModel::rowCount()
?
modList
does not affect tableModel
, but the item was referenced somewhere else. this cannot be tell from the code.