pippo42
30th April 2010, 16:02
Hello,
I have derived a class from QSqlRelationalDelegate and redefined the following functions.
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 *);
};
When I try to use it with a QDataWidgetMapper, I obtain a segmentation fault.
dataWidgetMapper->setItemDelegate(itemDelegate);
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!
I have derived a class from QSqlRelationalDelegate and redefined the following functions.
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 *);
};
When I try to use it with a QDataWidgetMapper, I obtain a segmentation fault.
dataWidgetMapper->setItemDelegate(itemDelegate);
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!