'Select the diagonal elements of the matrix'

def select_correct(self):

    selection = QItemSelection()
    n = self.tablemodel.rowCount()
    for i in range(2, n):
        index = self.tablemodel.index(i, i)
        selection.select(index, index)
    self.tableview.selectionModel().select(selection, QItemSelectionModel.ClearAndSelect)
