<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 the delegate.<br><br>However, this doesn'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. 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> def __init__(self, parts, parent=None):<br>
super(CodeColumnDelegate, self).__init__(parent)<br> self.parts = parts<br><br> def createEditor(self, parent, option, index):<br> return editors.CodeEditor(self.parts, self, parent)<br><br> def setEditorData(self, editor, index):<br>
value = index.data(Qt.EditRole).toPyObject()<br> if value:<br> for part_editor, part in zip(editor.part_editors, value):<br> part_editor.setText(unicode(part))<br><br> def setModelData(self, editor, model, index):<br>
print 'Set model data called !!!'<br> from camelot.types import Code<br> value = []<br> for part in editor.part_editors:<br> value.append(unicode(part.text()))<br> model.setData(index, create_constant_function(value))<br>
<br> def editingFinished(self, widget):<br> self.emit(QtCore.SIGNAL('commitData(QWidget*)'), widget)<br><br></div>