def bad_changed(item): if item.checkState() == Qt.Checked: item.setData(True, Qt.UserRole) else: item.setData(False, Qt.UserRole)