Results 1 to 2 of 2

Thread: QSqlRelationalDelegate

  1. #1
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default QSqlRelationalDelegate

    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!

  2. #2
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default Re: QSqlRelationalDelegate

    And if I attach the item delegate to the table view

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

    the createEditor function is called before the setEditorData and there is no longer a segmentation fault but the tableView behaves in a psychedelic way. If I edit something, the contents the cells are in a certain way mixed up. If I edit a cell, the cell where I was before takes the previous value of the cell I just modified.

    I guess I must be doing something wrong but I did exactly the same thing as in the documentation.

    Thanks!...

Similar Threads

  1. refreshing QSqlRelationalDelegate data
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2010, 01:54
  2. Replies: 1
    Last Post: 7th February 2010, 09:01
  3. Replies: 1
    Last Post: 20th January 2010, 23:59
  4. QSqlRelationalDelegate (ComboBox) id on first show
    By janus in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2008, 14:58
  5. Error in qsqlrelationaldelegate.h?
    By brcain in forum Qt Programming
    Replies: 3
    Last Post: 28th August 2006, 13:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.