|  | Home · All Classes · Modules

# QSqlRelation Class Reference
[QtSql module]

The QSqlRelation class stores information about an SQL foreign key. More...

### Methods

- __init__ (self)
- __init__ (self, QStringQString, QStringQString, QStringQString)
- __init__ (self, QSqlRelation)
- QStringQString displayColumn (self)
- QStringQString indexColumn (self)
- bool isValid (self)
- QStringQString tableName (self)

## Detailed Description

The QSqlRelation class stores information about an SQL foreign key.

QSqlRelation is a helper class for QSqlRelationalTableModel. See QSqlRelationalTableModel.setRelation() and QSqlRelationalTableModel.relation() for details.

See also QSqlRelationalTableModel, QSqlRelationalDelegate, and Relational Table Model Example.

## Method Documentation

### QSqlRelation.__init__ (self)

Constructs an invalid QSqlRelation object.

For such an object, the tableName(), indexColumn(), and displayColumn() functions return an empty string.

See also isValid().

### QSqlRelation.__init__ (self, QStringQString, QStringQString, QStringQString)

Constructs a QSqlRelation object, where tableName is the SQL table name to which a foreign key refers, indexColumn is the foreign key, and displayColumn is the field that should be presented to the user.

See also tableName(), indexColumn(), and displayColumn().

### QSqlRelation.__init__ (self, QSqlRelation)

### QStringQString QSqlRelation.displayColumn (self)

Returns the column from table tableName() that should be presented to the user instead of a foreign key.

### QStringQString QSqlRelation.indexColumn (self)

Returns the index column from table tableName() to which a foreign key refers.

### bool QSqlRelation.isValid (self)

Returns true if the QSqlRelation object is valid; otherwise returns false.

### QStringQString QSqlRelation.tableName (self)

Returns the name of the table to which a foreign key refers.