def selectionChanged(self, current_selection, previous_selection): self._updating_selection = True result = QListView.selectionChanged(self, current_selection, previous_selection) self.selectedIndex = current_selection.indexes()[0].row( ) if current_selection.indexes() else -1 self.selectedItemsChanged.emit() self._updating_selection = False return result