Well...it's working now, without my having to use the invalidate() method. Not sure what I changed, but here's the relevant code:
// qml
ListView {
id: spaceRow
model: spaceModel
delegate: TabButton {
contentItem: Text {
text: name
MouseArea {
anchors.fill: parent
onClicked: {
spaceRow.currentIndex = index
equipmentProxyModel.setSpaceIndex(index)
// c++
void EquipmentProxyModel::setSpaceIndex(int index)
{
m_spaceIndex = index;
}
m_spaceIndex is used here:
bool EquipmentProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
bool rc = false;
QModelIndex qmi = createIndex(sourceRow, 0);
QUuid equipmentUuid = m_equipmentModel->data(qmi, m_equipmentModel->UuidRole).toUuid();
QUuid spaceUuid = m_spaceModel->getUuid(m_spaceIndex);
if (m_spaceIndex == 0) { // all spaces
rc = true;
} else if (equipmentUuid.isNull()) {
// don't bother
} else {
rc = m_spaceModel->equipmentInSpace(spaceUuid, equipmentUuid);
}
return rc;
}
And this seems to suffice. Thanks to everyone who replied...
EDIT:
And...just like that, it stopped working (after some changes to the model. I followed the advice of @sierdzio and (re)inserted the invalidate() call:
void EquipmentProxyModel::setSpaceIndex(int index)
{
m_spaceIndex = index;
invalidate();
}
And now it works. No idea how I got it to work (temporarily) without this...