Hello, how would remove and insertrow look like for Martin Fitzpatricks example above?
First one needs def removeRows()/def InserRows() for the QAbstractTableModel class and also some behaviour inside the QMainwindow class
# This I have for my QAbstractTabelModel class
def insertRows(self, position, rows, QModelIndex, parent):
self.beginInsertRows(QModelIndex(), position, position+rows-1)
for i in range(rows):
default_row = ['']*len(self._headers)
self_data.insert(position, default_row)
self.endInsertRows()
return true
def removeRows(self, position, rows, QModelIndex, parent):
self.beginRemoveRows(QModelIndex(), position, position+rows-1)
for i in range(rows):
del(self._data[position])
self.endRemoveRows()
return true
Not sure if that is correct, Its what I’ve pieced together from examples on other sites.
For the QMainwindow class I’m not relay sure how to proceed, the examples on other sites are not very clear to understand.
Some structured extra explanation on this subject for Martins example of this would be helpful.
The row of data should be removed for both the model and the view.