[PySide] Editing multiple items in table view at once?

Hey guys,

i would like to know how it is possible to edit multiple items in a table view at once.
I have a custom table model, table view, item delegate and a itemselectionmodel set up.

When i’m selecting all items of a column and doubleclick the last one to enter edit mode,
only the last item changes after editing.
How would it be possible to change all selected items to the edited value?

Here is a screenshot that hopefully makes it a bit more clear:

you need to subclass QTableView and reimplement commitData.

This will show you how to get the value the user just entered, Once you have the value you can loop over the Selection Range to update the other cells with this value.

    
    def commitData(self, editor):
        
        # call parent commitData first
        super(WeightsTableView, self).commitData(editor)
        
        theModel = self.currentIndex().model()

        value = theModel.data(self.currentIndex(), QtCore.Qt.EditRole)
        curRow, curCol = self.currentIndex().row(), self.currentIndex().column()

        for itemRange in self.selectionModel().selection():
            # do stuff here!



Well, i thought it would work like that. I was curious though, if there might have been some magic QtCore.Qt.SelectionModeRowComplete enum or similiar.
Thanks a lot :slight_smile: