I want to perform a sort of rows in QTableView, so that the underlying TableModel would have its data sorted, too:
You have several problems in your code I will address just two here:
Model.moveRows
with the wrong arguments:self.model().moveRows(QModelIndex(), 0, 0, QModelIndex(), 1)
self.model().moveRows(QModelIndex(), 1, 1, QModelIndex(), 0)
self.data = self.data[1] + self.data[0] + self.data[2]
self.data = [self.data[1], self.data[0] , self.data[2]]
Note: problem 1 is the one who is provoking the exception on your code. Also note that is a bad idea naming an instance variable and a function the same (Model.data
)