'Select the off-diagonal elements of the matrix'

def select_wrong(self):

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