Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QSqlRelationalTableModel class provides an editable data model for a single database table. In addition, columns can be set as foreign keys into another table. More...
#include <QSqlRelationalTableModel>
Inherits QSqlTableModel.
The QSqlRelationalTableModel class provides an editable data model for a single database table. In addition, columns can be set as foreign keys into another table.
QSqlRelationalTableModel acts like QSqlTableModel, but allows columns to be set as foreign keys into other database tables.
The following example assumes that there are two tables called people and titles. The titles table has two columns called id and title. The people table's 4th column is a foreign index into the titles table:
QSqlTableModel model; model.setTable("people"); model.setRelation(3, QSqlRelation("titles", "id", "title")); model.select();
Instead of displaying the id of the title, the model will display the value stored in the title column of the titles table.
Creates an empty QSqlRelationalTableModel and sets the parent to parent and the database connection to db. If db is not valid, the default database connection will be used.
Destroys the object and frees any allocated resources.
Returns the data stored under the given role for the item referred to by index. Returns an invalid variant if index is out of bounds.
Reimplemented from QAbstractItemModel.
Returns the relation for the column column.
Sets the data for the role in the item with the specified index to the value given. Depending on the edit strategy, the value might be applied to the database at once, or it may be cached in the model.
Returns true if the value could be set, or false on error (for example, if index is out of bounds).
For relational columns, value has to be the index, not the display value.
Reimplemented from QAbstractItemModel.
See also editStrategy(), data(), submitChanges(), and revertRow().
Lets the specified column be a foreign index specified by relation.
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp2 |