Both of those could be done with the setSelected
method of QListWidgetItem
s.
# select item
listWidget.item(row).setSelected(True)
# deselect item
listWidget.item(row).setSelected(False)
You can do this for multiple items and as long as you have MultipleSelection
enabled, it would select/deselect those items.