code: def commitAndCloseEditor(self):
          
          editor = self.sender()
          # Avoid a segfault with PyQt5. Variable value won't be changed
          # but at least Spyder won't crash. It seems generated by a bug in sip.
          try:
              self.commitData.emit(editor)
          except AttributeError:
              pass
          self.closeEditor.emit(editor, QAbstractItemDelegate.NoHint)
docs: Commit and close editor