42 #ifndef QSQLRELATIONALDELEGATE_H 43 #define QSQLRELATIONALDELEGATE_H 47 #include <QtGui/qitemdelegate.h> 48 #include <QtGui/qlistview.h> 49 #include <QtGui/qcombobox.h> 50 #include <QtSql/qsqlrelationaltablemodel.h> 90 if (!sqlModel || !combo) {
94 combo->setCurrentIndex(combo->findText(sqlModel->
data(index).
toString()));
105 if (!sqlModel || !childModel || !combo) {
111 int childColIndex = childModel->fieldIndex(sqlModel->
relation(index.
column()).displayColumn());
112 int childEditIndex = childModel->fieldIndex(sqlModel->
relation(index.
column()).indexColumn());
117 childModel->
data(childModel->index(currentItem, childEditIndex),
Qt::EditRole),
129 #endif // QSQLRELATIONALDELEGATE_H T qobject_cast(QObject *object)
The QSqlRelationalTableModel class provides an editable data model for a single database table...
#define QT_END_NAMESPACE
This macro expands to.
virtual QSqlTableModel * relationModel(int column) const
Returns a QSqlTableModel object for accessing the table for which column is a foreign key...
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Gets data from the editor widget and stores it in the specified model at the item index...
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void setModelColumn(int visibleColumn)
The QObject class is the base class of all Qt objects.
#define QT_BEGIN_NAMESPACE
This macro expands to.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
The QComboBox widget is a combined button and popup list.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the widget used to edit the item specified by index for editing.
QSqlRelation relation(int column) const
Returns the relation for the column column, or an invalid relation if no relation is set...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemModel class provides the abstract interface for item model classes.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const
Reimplemented Function
void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the data to be displayed and edited by the editor from the data model item specified by the mode...
void setModel(QAbstractItemModel *model)
Sets the model to be model.
The QItemDelegate class provides display and editing facilities for data items from a model...
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
The QModelIndex class is used to locate data in a data model.
The QSqlRelationalDelegate class provides a delegate that is used to display and edit data from a QSq...
The QSqlTableModel class provides an editable data model for a single database table.
int currentIndex
the index of the current item in the combobox.
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
bool setData(const QModelIndex &item, const QVariant &value, int role=Qt::EditRole)
Sets the data for the role in the item with the specified index to the value given.
int column() const
Returns the column this model index refers to.