QSqlRelation#

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

Inheritance diagram of PySide6.QtSql.QSqlRelation

Synopsis#

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

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

See also

QSqlRelationalTableModel QSqlRelationalDelegate Relational Table Model Example

class PySide6.QtSql.QSqlRelation#

PySide6.QtSql.QSqlRelation(aTableName, indexCol, displayCol)

Parameters:
  • indexCol – str

  • aTableName – str

  • displayCol – str

Constructs an invalid QSqlRelation object.

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

See also

isValid()

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.

PySide6.QtSql.QSqlRelation.displayColumn()#
Return type:

str

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

PySide6.QtSql.QSqlRelation.indexColumn()#
Return type:

str

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

PySide6.QtSql.QSqlRelation.isValid()#
Return type:

bool

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

PySide6.QtSql.QSqlRelation.swap(other)#
Parameters:

otherPySide6.QtSql.QSqlRelation

Swaps this with other.

PySide6.QtSql.QSqlRelation.tableName()#
Return type:

str

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