[PyQt] commitData signal with custom delegates

Erik Janssens Erik.Janssens at conceptive.be
Wed Oct 1 10:15:56 BST 2008

Dear all,

I have created a custom editor widget together with a custom delegates,
used in a form together with a QDataWidgetMapper.

According to the documentation (and the source code confirms this), when
the editor has finished editing, the delegate should emit the commitData
signal, if this is received by the QDataWidgetMapper, this one should call
the setModelData method of  the delegate.

However, this doesn't seem to work, as far as I can see, the commitData
signal is emitted, but the setModelData never gets called, please find below
the code of the delegate.  The full source code is at :

username and passwd : guest/guest

Any help or suggestion is appreciated !

Best regards,


class CodeColumnDelegate(QtGui.QItemDelegate):

  def __init__(self, parts, parent=None):
    super(CodeColumnDelegate, self).__init__(parent)
    self.parts = parts

  def createEditor(self, parent, option, index):
    return editors.CodeEditor(self.parts, self, parent)

  def setEditorData(self, editor, index):
    value = index.data(Qt.EditRole).toPyObject()
    if value:
      for part_editor, part in zip(editor.part_editors, value):

  def setModelData(self, editor, model, index):
    print 'Set model data called !!!'
    from camelot.types import Code
    value = []
    for part in editor.part_editors:
    model.setData(index, create_constant_function(value))

  def editingFinished(self, widget):
    self.emit(QtCore.SIGNAL('commitData(QWidget*)'), widget)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20081001/f32f9b58/attachment.html

More information about the PyQt mailing list