To quote from the video tutorial regarding setData
:
...this function needs to return true if the operation was successful, or else the view will not update itself.
Strictly speaking, this statement is false. The documentation for QAbstractItemModel only says that setData
returns true if the data was set successfully, and false otherwise; it does not mention what the consequences of this might be. Specifically, it does not mention anything about updating the view.
Looking at the Qt source code, the return value of setData
does get checked in a few places, and some of those checks can sometimes help trigger an update. But there are literally dozens of things that can trigger an update, so the return value of setData
is in no way essential for updating items.
Perhaps it would have been more accurate to say that setData
should return true, otherwise the view may not update itself (under certain circumstances).