Hello,
I have derived a class from QSqlRelationalDelegate and redefined the following functions.
Q_OBJECT
public:
~ItemDelegate();
void addRelatedModel(RelatedModel *);
};
class ItemDelegate : public QSqlRelationalDelegate{
Q_OBJECT
public:
ItemDelegate(QObject *parent=0);
~ItemDelegate();
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void addRelatedModel(RelatedModel *);
};
To copy to clipboard, switch view to plain text mode
When I try to use it with a QDataWidgetMapper, I obtain a segmentation fault.
dataWidgetMapper->setItemDelegate(itemDelegate);
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!
Bookmarks