Hello,

I have derived a class from QSqlRelationalDelegate and redefined the following functions.

Qt Code:
  1. class ItemDelegate : public QSqlRelationalDelegate{
  2. Q_OBJECT
  3. public:
  4. ItemDelegate(QObject *parent=0);
  5. ~ItemDelegate();
  6. QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
  7. void setEditorData(QWidget *editor, const QModelIndex &index) const;
  8. void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
  9. void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
  10. void addRelatedModel(RelatedModel *);
  11. };
To copy to clipboard, switch view to plain text mode 

When I try to use it with a QDataWidgetMapper, I obtain a segmentation fault.

Qt Code:
  1. dataWidgetMapper->setItemDelegate(itemDelegate);
To copy to clipboard, switch view to plain text mode 

I have debugged and found out that the function createEditor is not called but setEditorData is, The segmentation fault occurs when it tries to use the editor that has not been initialised.

What I am doing wrong?

Thank you for your help!