I was trying to optimize some code in Kalendar and replace a beginResetModel/endResetModel
with a dataChanged
since only the data were updated/reset, but the size of the model didn’t change.
This was my code:
Q_EMIT dataChanged(index(0, 0), index(rowCount({}), 0));`
Unfortunately, this didn’t work and after a dataChanged
my data
method didn’t get called. Can you spot the mistake? It turned out to by an off my one mistake. index(rowCount({}), 0)
is outside of the model and has such an invalid index. This made the entire dataChanged
silently fail.
Here is the working code
Q_EMIT dataChanged(index(0, 0), index(rowCount({}) - 1, 0));`