QSqlRelationalDelegate Class
The QSqlRelationalDelegate class provides a delegate that is used to display and edit data from a QSqlRelationalTableModel. 更多...
头文件: | #include <QSqlRelationalDelegate> |
qmake: | QT += sql |
基类: | QItemDelegate |
公有函数
QSqlRelationalDelegate(QObject *parent = nullptr) | |
~QSqlRelationalDelegate() |
重新实现的公有函数
virtual QWidget * | createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override |
virtual void | setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override |
- 10 个公有函数继承自 QItemDelegate
- 9 个公有函数继承自 QAbstractItemDelegate
其他继承的成员
- 1 个属性继承自 QItemDelegate
- 3 个信号继承自 QAbstractItemDelegate
- 7 个受保护的函数继承自 QItemDelegate
详细描述
The QSqlRelationalDelegate class provides a delegate that is used to display and edit data from a QSqlRelationalTableModel.
Unlike the default delegate, QSqlRelationalDelegate provides a combobox for fields that are foreign keys into other tables. To use the class, simply call QAbstractItemView::setItemDelegate() on the view with an instance of QSqlRelationalDelegate:
QTableView *view = new QTableView; view->setModel(model); view->setItemDelegate(new QSqlRelationalDelegate(view));
The Relational Table Model example (shown below) illustrates how to use QSqlRelationalDelegate in conjunction with QSqlRelationalTableModel to provide tables with foreign key support.
参见 QSqlRelationalTableModel and Model/View Programming.
成员函数
QSqlRelationalDelegate::QSqlRelationalDelegate(QObject *parent = nullptr)
Constructs a QSqlRelationalDelegate object with the given parent.
QSqlRelationalDelegate::~QSqlRelationalDelegate()
Destroys the QSqlRelationalDelegate object and frees any allocated resources.
[override virtual]
QWidget *QSqlRelationalDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
重新实现 QAbstractItemDelegate::createEditor().