<div dir="ltr">Dear all,<br><br>I have created a custom editor widget together with a custom delegates,<br>used in a form together with a QDataWidgetMapper.<br><br>According to the documentation (and the source code confirms this), when<br>
the editor has finished editing, the delegate should emit the commitData<br>signal, if this is received by the QDataWidgetMapper, this one should call<br>the setModelData method of&nbsp; the delegate.<br><br>However, this doesn&#39;t seem to work, as far as I can see, the commitData<br>
signal is emitted, but the setModelData never gets called, please find below<br>the code of the delegate.&nbsp; The full source code is at :<br><br><a href="http://www.conceptive.be/camelot/svn/trunk/camelot/view/controls/delegates.py">http://www.conceptive.be/camelot/svn/trunk/camelot/view/controls/delegates.py</a> <br>
username and passwd : guest/guest<br><br>Any help or suggestion is appreciated !<br><br>Best regards,<br><br>Erik<br><br><br><br>class CodeColumnDelegate(QtGui.QItemDelegate):<br><br>&nbsp; def __init__(self, parts, parent=None):<br>
&nbsp;&nbsp;&nbsp; super(CodeColumnDelegate, self).__init__(parent)<br>&nbsp;&nbsp;&nbsp; self.parts = parts<br><br>&nbsp; def createEditor(self, parent, option, index):<br>&nbsp;&nbsp;&nbsp; return editors.CodeEditor(self.parts, self, parent)<br><br>&nbsp; def setEditorData(self, editor, index):<br>
&nbsp;&nbsp;&nbsp; value = index.data(Qt.EditRole).toPyObject()<br>&nbsp;&nbsp;&nbsp; if value:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for part_editor, part in zip(editor.part_editors, value):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; part_editor.setText(unicode(part))<br><br>&nbsp; def setModelData(self, editor, model, index):<br>
&nbsp;&nbsp;&nbsp; print &#39;Set model data called !!!&#39;<br>&nbsp;&nbsp;&nbsp; from camelot.types import Code<br>&nbsp;&nbsp;&nbsp; value = []<br>&nbsp;&nbsp;&nbsp; for part in editor.part_editors:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value.append(unicode(part.text()))<br>&nbsp;&nbsp;&nbsp; model.setData(index, create_constant_function(value))<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp; def editingFinished(self, widget):<br>&nbsp;&nbsp;&nbsp; self.emit(QtCore.SIGNAL(&#39;commitData(QWidget*)&#39;), widget)<br><br></div>