Den tis 21 sep. 2021 16:00Murphy, Sean <sean.mur...@centauricorp.com> skrev:
> > I'm having an issue where my proxy model and its associated view aren't > > updating live when changes are made in the source model. > > > > My proxy model simply is attempting to invert the rows of the source > model. So > > it inherits from a QSortFilterProxyModel and implements mapFromSource() > and > > mapToSource() as follows: > > > > QModelIndex invertRowsModel::mapFromSource(const QModelIndex > > &sourceIndex) const > > { > > if(sourceIndex.isValid() && rowCount() > 0) > > { > > return this->index(rowCount() - sourceIndex.row() - 1, > > sourceIndex.column()); > > } > > > > return QModelIndex(); > > } > > > > Small update here, but I'm not sure what it actually means... I added a > debug > statement at the top of my mapFromSource() function, so now that function > reads like so: > > QModelIndex invertRowsModel::mapFromSource(const QModelIndex > &sourceIndex) const > { > if(sourceIndex.isValid() && rowCount() > 0) > { > qDebug() << __FUNCTION__ << "valid index" << sourceIndex; > return this->index(rowCount() - sourceIndex.row() - 1, > sourceIndex.column()); > } else { > qDebug() << __FUNCTION__ << "invalid index" << sourceIndex; > } > > return QModelIndex(); > } > > With this in place, while modifying the data in the source view, I NEVER > see the > mapFromSource() "valid index" debug message from the proxy model. Right > after > setData() is called in the source model, I see a couple of these messages > come out > and that's it: > > invertRowsModel::mapFromSource invalid index > QModelIndex(-1,-1,0x0,QObject(0x0)) > > I'm not sure exactly what that means or how to address it, but it is a new > data point... > I added the same kind of printout and concluded the same yesterday, when I thought I'd help you debug as a challenge.. (then ran out of time). Curious to see how this progresses.. Code in QSFPM for handling source model dataChanged is a bit hard to follow.. Elvis > Sean > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > https://lists.qt-project.org/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest