In my model class I have
<code>class OnCallDutyList(QAbstractListModel):
...
def addEvent(self, event):
index = QModelIndex()
self.beginInsertRows(index, self.rowCount(index), self.rowCount(index))
self._events.append(event)
self._events.sort(key=lambda x: x["start"], reverse=False)
self.endInsertRows()
</code>
<code>class OnCallDutyList(QAbstractListModel):
...
def addEvent(self, event):
index = QModelIndex()
self.beginInsertRows(index, self.rowCount(index), self.rowCount(index))
self._events.append(event)
self._events.sort(key=lambda x: x["start"], reverse=False)
self.endInsertRows()
</code>
class OnCallDutyList(QAbstractListModel):
...
def addEvent(self, event):
index = QModelIndex()
self.beginInsertRows(index, self.rowCount(index), self.rowCount(index))
self._events.append(event)
self._events.sort(key=lambda x: x["start"], reverse=False)
self.endInsertRows()
Then connecting the event in parent class
<code>self.ocdModel.dataChanged.connect(lambda: self.saveOCD())
</code>
<code>self.ocdModel.dataChanged.connect(lambda: self.saveOCD())
</code>
self.ocdModel.dataChanged.connect(lambda: self.saveOCD())
However, saveOCD
never fires. I was thinking endInsertRows()
should emit the event.
What is the right event for listening to add/remove events in QAbstractListModel
?