def setData(self, index, value, role): if role == Qt.CheckStateRole and index.column() == 0: self.layoutAboutToBeChanged.emit() for i, v in self.checks.items(): if are_parent_and_child(index, i): self.checks.pop(i) self.checks[index] = value #self.childCount(index) self.layoutChanged.emit() return True return QFileSystemModel.setData(self, index, value, role)