Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSqlRelation Class Reference

\inmodule QtSql More...

#include <qsqlrelationaltablemodel.h>

+ Collaboration diagram for QSqlRelation:

Public Member Functions

 QSqlRelation ()
 Constructs an invalid QSqlRelation object.
 
 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, indexColumn is the foreign key, and displayColumn is the field that should be presented to the user.
 
void swap (QSqlRelation &other) noexcept
 Swaps this with other.
 
QString tableName () const
 Returns the name of the table to which a foreign key refers.
 
QString indexColumn () const
 Returns the index column from table tableName() to which a foreign key refers.
 
QString displayColumn () const
 Returns the column from table tableName() that should be presented to the user instead of a foreign key.
 
bool isValid () const noexcept
 Returns true if the QSqlRelation object is valid; otherwise returns false.
 

Detailed Description

\inmodule QtSql

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, {Relational Table Model Example}

Definition at line 17 of file qsqlrelationaltablemodel.h.

Constructor & Destructor Documentation

◆ QSqlRelation() [1/2]

QSqlRelation::QSqlRelation ( )
inline

Constructs an invalid QSqlRelation object.

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

See also
isValid()

Definition at line 20 of file qsqlrelationaltablemodel.h.

◆ QSqlRelation() [2/2]

QSqlRelation::QSqlRelation ( const QString & tableName,
const QString & indexColumn,
const QString & displayColumn )
inline

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(), displayColumn()

Definition at line 21 of file qsqlrelationaltablemodel.h.

Member Function Documentation

◆ displayColumn()

QString QSqlRelation::displayColumn ( ) const
inline

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

Definition at line 36 of file qsqlrelationaltablemodel.h.

Referenced by QSqlRelationalTableModel::orderByClause(), QRelation::populateDictionary(), and QSqlRelationalTableModel::selectStatement().

+ Here is the caller graph for this function:

◆ indexColumn()

QString QSqlRelation::indexColumn ( ) const
inline

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

Definition at line 34 of file qsqlrelationaltablemodel.h.

Referenced by QRelation::populateDictionary(), and QSqlRelationalTableModel::selectStatement().

+ Here is the caller graph for this function:

◆ isValid()

bool QSqlRelation::isValid ( ) const
inlinenoexcept

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

Definition at line 38 of file qsqlrelationaltablemodel.h.

Referenced by QRelation::isValid(), QSqlRelationalTableModel::orderByClause(), QSqlRelationalTableModel::relationModel(), and QSqlRelationalTableModel::selectStatement().

+ Here is the caller graph for this function:

◆ swap()

void QSqlRelation::swap ( QSqlRelation & other)
inlinenoexcept

Swaps this with other.

Definition at line 25 of file qsqlrelationaltablemodel.h.

References other().

+ Here is the call graph for this function:

◆ tableName()

QString QSqlRelation::tableName ( ) const
inline

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

Definition at line 32 of file qsqlrelationaltablemodel.h.

Referenced by QRelation::populateModel(), and QSqlRelationalTableModel::selectStatement().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: