
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQSqlRelationalDelegate class provides a delegate that is used to display and edit data from aQSqlRelationalTableModel.More...
| Header: | #include <QSqlRelationalDelegate> |
| Inherits: | QItemDelegate |
| QSqlRelationalDelegate(QObject * parent = 0) | |
| ~QSqlRelationalDelegate() |
| virtual QWidget * | createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const |
| virtual void | setEditorData(QWidget * editor, const QModelIndex & index) const |
| virtual void | setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const |
TheQSqlRelationalDelegate class provides a delegate that is used to display and edit data from aQSqlRelationalTableModel.
Unlike the default delegate,QSqlRelationalDelegate provides a combobox for fields that are foreign keys into other tables. To use the class, simply callQAbstractItemView::setItemDelegate() on the view with an instance ofQSqlRelationalDelegate:
QTableView*view=newQTableView; view->setModel(model); view->setItemDelegate(newQSqlRelationalDelegate(view));
TheRelational Table Model example (shown below) illustrates how to useQSqlRelationalDelegate in conjunction withQSqlRelationalTableModel to provide tables with foreign key support.

See alsoQSqlRelationalTableModel andModel/View Programming.
Constructs aQSqlRelationalDelegate object with the givenparent.
Destroys theQSqlRelationalDelegate object and frees any allocated resources.
[virtual]QWidget * QSqlRelationalDelegate::createEditor(QWidget * parent, constQStyleOptionViewItem & option, constQModelIndex & index) constReimplemented fromQAbstractItemDelegate::createEditor().
[virtual]void QSqlRelationalDelegate::setEditorData(QWidget * editor, constQModelIndex & index) constReimplemented fromQAbstractItemDelegate::setEditorData().
[virtual]void QSqlRelationalDelegate::setModelData(QWidget * editor,QAbstractItemModel * model, constQModelIndex & index) constReimplemented fromQAbstractItemDelegate::setModelData().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.