Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.5
-
None
-
db321e74413ac088edaa209a57ad5147175df041 (qt/qtdeclarative/5.14)
Description
Had ListView with QList<QObject*> model. Let say user ask to delete currently selected object. Apps delete object, update model and set currentIndex to -1. Everything alright, onCurrentIndexChanged is printing info about setting currentIndex to -1:
onCurrentIndexChanged: console.log("currentIndex" + currentIndex)
But if the object was the last object and updated model is become empty, Qt automatically set currentIndex of ListView to -1 without emitting CurrentIndexChanged. And setting currentIndex -1 in app does nothing, because it is already -1!
So all bindings with currentIndex will not be updated in this case:
enabled: idList.currentIndex >= 0
I suppose that ListView should emit currentIndexChanged -1 in this case.
For now in places where currentIndex is needed a workaround is to check with currentIndex also model.length.
enabled: ((idList.model.length > 0) && (idList.currentIndex >= 0))
Attachments
For Gerrit Dashboard: QTBUG-68232 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
279608,5 | QQuickItemView: Emit correct change signal on model reset | 5.13 | qt/qtdeclarative | Status: ABANDONED | 0 | 0 |
283598,5 | QQuickItemView: Emit correct change signal on model reset | 5.14 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
283659,1 | QQuickItemView: Emit correct change signal on model reset | 5.14 | qt/qtdeclarative | Status: ABANDONED | -1 | 0 |