I'm coding a reddit bot and created a UI like this:
What I want to do is user selects an account from list, clicks the remove selected account and all checked accounts deleted from list. So here is my code:
def delete_selected_accounts(self):
print(len(self.account_list))
for i in range(self.model.rowCount()):
if self.model.item(i).checkState() == Qt.Checked:
self.model.removeRow(i)
self.account_list.pop(i)
However, this code does not work as expected. When I removeRow from a model or pop from the account list, count of lists changes and I'm getting list out of range problem. What can I do to delete selected item without this problem?