code: def setModelData(self, editor, model, index):
          
          if not hasattr(model, "set_value"):
              # Read-only mode
              return
          
          if isinstance(editor, QLineEdit):
              value = editor.text()
              try:
                  value = display_to_value(to_qvariant(value),
                                           self.get_value(index),
                                           ignore_errors=False)
              except Exception as msg:
                  raise
                  QMessageBox.critical(editor, _("Edit item"),
                                       _("<b>Unable to assign data to item.</b>"
                                         "<br><br>Error message:<br>%s"
                                         ) % str(msg))
                  return
          elif isinstance(editor, QDateEdit):
              qdate = editor.date()
              value = datetime.date( qdate.year(), qdate.month(), qdate.day() )
          elif isinstance(editor, QDateTimeEdit):
              qdatetime = editor.dateTime()
              qdate = qdatetime.date()
              qtime = qdatetime.time()
              value = datetime.datetime( qdate.year(), qdate.month(),
                                         qdate.day(), qtime.hour(),
                                         qtime.minute(), qtime.second() )
          else:
              # Should not happen...
              raise RuntimeError("Unsupported editor widget")
          self.set_value(index, value)
docs: Overriding method setModelData
          Editor --> Model