4#ifndef QSQLRELATIONALDELEGATE_H
5#define QSQLRELATIONALDELEGATE_H
7#include <QtSql/qtsqlglobal.h>
13#include <QtWidgets/qstyleditemdelegate.h>
14#if QT_CONFIG(listview)
15#include <QtWidgets/qlistview.h>
17#if QT_CONFIG(combobox)
18#include <QtWidgets/qcombobox.h>
20#include <QtSql/qsqldriver.h>
21#include <QtSql/qsqlrelationaltablemodel.h>
22#include <QtCore/qmetaobject.h>
47 const QStyleOptionViewItem &
option,
54 const QSqlDriver *
const driver = childModel->database().driver();
59 sqlModel->relation(
index.column()).displayColumn()));
70 if (qobject_cast<QComboBox *>(editor)) {
93 QComboBox *combo = qobject_cast<QComboBox *>(editor);
94 if (!sqlModel || !childModel || !combo) {
98 const QSqlDriver *
const driver = childModel->database().driver();
101 int childColIndex = fieldIndex(childModel, driver,
102 sqlModel->relation(
index.column()).displayColumn());
103 int childEditIndex = fieldIndex(childModel, driver,
104 sqlModel->relation(
index.column()).indexColumn());
105 sqlModel->setData(
index,
106 childModel->data(childModel->index(currentItem, childColIndex),
Qt::DisplayRole),
108 sqlModel->setData(
index,
109 childModel->data(childModel->index(currentItem, childEditIndex),
Qt::EditRole),
The QComboBox widget combines a button with a dropdown list.
void setModelColumn(int visibleColumn)
virtual void setModel(QAbstractItemModel *model)
Sets the model to be model.
int currentIndex
the index of the current item in the combobox.
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
The QSqlRelationalTableModel class provides an editable data model for a single database table,...
The QSqlTableModel class provides an editable data model for a single database table.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the data to be displayed and edited by the editor from the data model item specified by the mode...
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Gets data from the editor widget and stores it in the specified model at the item index.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the widget used to edit the item specified by index for editing.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
Combined button and popup list for selecting options.
static glyph_t stripped(glyph_t glyph)
GLsizei const GLfloat * v
[13]
#define QT_REQUIRE_CONFIG(feature)
QSqlQueryModel * model
[16]