def setModelData(self, editor: QtGui.QWidget, model: QtCore.QAbstractItemModel, index: QtCore.QModelIndex) -> None: assert isinstance(editor, QtGui.QLineEdit) text = editor.text() model.setData(index, text.title() if editor.hasAcceptableInput() else text, QtCore.Qt.EditRole)
def setModelData(self, editor: QtGui.QWidget, model: QtCore.QAbstractItemModel, index: QtCore.QModelIndex) -> None: assert isinstance(editor, QtGui.QLineEdit) text = editor.text() if editor.hasAcceptableInput() and not text.startswith("+2"): text = "+2" + text model.setData(index, text, QtCore.Qt.EditRole)