42 #ifndef QSQLRELATIONALTABLEMODEL_H 43 #define QSQLRELATIONALTABLEMODEL_H 45 #include <QtSql/qsqltablemodel.h> 59 : tName(aTableName), iColumn(indexCol), dColumn(displayCol) {}
67 {
return !(tName.isEmpty() || iColumn.isEmpty() || dColumn.isEmpty()); }
96 virtual void setRelation(
int column,
const QSqlRelation &relation);
118 #endif // QSQLRELATIONALTABLEMODEL_H The QVariant class acts like a union for the most common Qt data types.
The QSqlRelationalTableModel class provides an editable data model for a single database table...
QSqlRelation(const QString &aTableName, const QString &indexCol, const QString &displayCol)
Constructs a QSqlRelation object, where tableName is the SQL table name to which a foreign key refers...
virtual QString selectStatement() const
Returns the SQL SELECT statement used internally to populate the model.
#define QT_END_NAMESPACE
This macro expands to.
QSqlRelation()
Constructs an invalid QSqlRelation object.
QString tableName() const
Returns the name of the table to which a foreign key refers.
The QSqlDatabase class represents a connection to a database.
JoinMode
This enum specifies the type of mode to use when joining two tables.
The QSqlRecord class encapsulates a database record.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
void clear()
Reimplemented Function
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual void setTable(const QString &tableName)
Sets the database table on which the model operates to tableName.
virtual bool insertRowIntoTable(const QSqlRecord &values)
Inserts the values values into the currently active database table.
virtual bool updateRowInTable(int row, const QSqlRecord &values)
Updates the given row in the currently active database table with the specified values.
virtual QString orderByClause() const
Returns an SQL ORDER BY clause based on the currently set sort order.
The QSqlRelation class stores information about an SQL foreign key.
bool isValid() const
Returns true if the QSqlRelation object is valid; otherwise returns false.
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Removes count columns from the parent model, starting at index column.
QString indexColumn() const
Returns the index column from table tableName() to which a foreign key refers.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the data for the item index for the role role to value.
The QModelIndex class is used to locate data in a data model.
The QSqlTableModel class provides an editable data model for a single database table.
virtual bool select()
Populates the model with data from the table that was set via setTable(), using the specified filter ...
QString displayColumn() const
Returns the column from table tableName() that should be presented to the user instead of a foreign k...
#define Q_DECLARE_PRIVATE(Class)
virtual void revertRow(int row)
Reverts all changes for the specified row.
QVariant data(const QModelIndex &idx, int role=Qt::DisplayRole) const
Reimplemented Function