[Interest] Proxied view not updating live when source model does

Murphy, Sean Sean.Murphy at centauricorp.com
Wed Sep 22 20:04:57 CEST 2021

> to both rowCount() and columnCount() removed those errors and now my
> application runs silently.

I should have explained better. It runs silently in the sense that 
the QAbstractItemModelTester instances aren't printing out 
any information any more.

The broken behavior still exists where the view connected to the 
proxy model isn't repainting the corresponding row as the source 
model's data changes. Instead it is repainting the same row as 
the source.

For example:  
1. If initially populate the source model with 3 rows of data
      A  1
      B  2
      C  3
  The proxied view correctly shows this data inverted:
      C 3
      B 2
      A 1
2. If I then edit cell (0,0) in the source view from 'A' to 'Z':
      Z  1
      B  2
      C  3
  The proxied view doesn't update, still showing an 'A' in cell 
  (2,0) which is supposed to map to source (0,0):
      C 3
      B 2
      A 1
3. If I then edit cell (2,0) in the source view from 'C' to 'X':
      Z  1
      B  2
      X  3
  The proxy view updates to:
      C 3
      B 2
      Z 1

I still think the problem is that the dataChanged() signal that 
automatically gets emitted by the proxy model off from the 
source model's dataChanged() signal has the EXACT SAME 
INDEX as the source model:

"baseModel::slotDataChanged: Index: (2, 0)"
"invertRowsModel::slotDataChanged: Index: (2, 0)"

I think the correct behavior for the proxy should be that when 
the source's dataChanged() signal fires, the indices in that 
signal should be translated through mapFromSource() to then 
get re-emitted from the proxy model so the attached view would 
then call the proxy's data() with the mapped index (in this example, 
when source data changes at (2,0) the proxied view should be 
informed that index (0,0) changed to refresh that data), but that 
doesn't seem to be happening automatically...


More information about the Interest mailing list