Though this thread is rather old, I’m posting this in the event someone else comes across the same situation. Even though I indicated that I thought I had found the problem. It wasn’t until a bit later that I figured out the real problem.
It turns out that the QAbstractItemModel documentation for dataChanged(), states among other things that...
[signal] void QAbstractItemModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int> ())
...
The optional roles argument can be used to specify which data roles have actually been modified. An empty vector in the roles argument means that all roles should be considered modified. The order of elements in the roles argument does not have any relevance.
Based on other Qt documentation that shows a value assigned to an argument apparently indicating that it is an optional argument, and that I wanted to address all roles, I assumed (erroneously), that if you wanted to address all of the rolls the role argument could be an empty vector, or the role argument was optional. However, emitting the signal without a role argument appeared to work but proved to be problematic. Then, when I came across the QAbstractItemView documentation for the dataChanged() signal, it stated in part...
[virtual protected slot] void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int> ())
...
The roles which have been changed can either be an empty container (meaning everything has changed), or a non-empty container with the subset of roles which have changed.
Which I took to mean that the role argument itself is not optional and a container must be used as the argument, but the contents of the container can be empty if you want to address all roles.
Sending an empty container QVector<int> solved the problem.
Bookmarks