Quote Originally Posted by d_stranz View Post
...does your override of rowCount() ever get called?
Yes, it gets called properly. I modified my override to confirm:

Qt Code:
  1. int DecoratorProxyModel::rowCount(const QModelIndex &parent) const
  2. {
  3. qDebug() << "proxy rowCount() call, sourceModel():" << sourceModel()->rowCount(parent) << "base class rowCount():" << QSortFilterProxyModel::rowCount(parent);
  4. qDebug() << "modified rowCount() response:" << sourceModel()->rowCount(parent) + 1;
  5. return sourceModel()->rowCount(parent) + 1;
  6. // return QSortFilterProxyModel::rowCount(parent) + 1;
  7. }
To copy to clipboard, switch view to plain text mode 

Both implementations, using the source model rowCount() and using the base class rowCount() report the same number of rows.

Debug output:
Qt Code:
  1. > Source model initModel(), rows: 7
  2. proxy rowCount() call, sourceModel()->rowC: 7 base class rowCount(): 7
  3. modified rowCount() response: 8
  4. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  5. modified rowCount() response: 8
  6. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  7. modified rowCount() response: 8
  8. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  9. modified rowCount() response: 8
  10. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  11. modified rowCount() response: 8
  12. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  13. modified rowCount() response: 8
  14. proxy rowCount() call, sourceModel(): 7 base class rowCount(): 7
  15. modified rowCount() response: 8
To copy to clipboard, switch view to plain text mode 

Quote Originally Posted by d_stranz View Post
Have you also overridden the QSortFilterProxyModel::filterAcceptsRow() protected method?
No, I didn't touch the QSortFilterProxyModel::filterAcceptsRow() method. In fact, I've read Qt docs and found out that it is better to use QIdentityProxyModel if I just want to modify the output. So, I tried subclassing identity proxy overriding only rowCount() and data() methods with the same code I did for sortfilter proxy, but it didn't help, the view doesn't call the data() method for that additional virtual rowCount()+1 row.

I also tried fiddling with the QSortFilterProxyModel::flags(), but seems like it doesn't get called for the virtual row either.
Qt Code:
  1. Qt::ItemFlags DecoratorProxyModel::flags(const QModelIndex &index) const
  2. {
  3. qint32 row = index.row();
  4. qint32 col = index.column();
  5. qDebug() << "flags():" << row << col;
  6. return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
  7. }
To copy to clipboard, switch view to plain text mode 

And I thought I understood how Qt's Model View framework works :-)