Qt 4.8
Public Functions | Properties | List of all members
QSqlRelation Class Reference

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

#include <qsqlrelationaltablemodel.h>

Public Functions

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

Properties

QString dColumn
 
QString iColumn
 
QString tName
 

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

Definition at line 53 of file qsqlrelationaltablemodel.h.

Constructors and Destructors

◆ 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 56 of file qsqlrelationaltablemodel.h.

56 {}

◆ 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 57 of file qsqlrelationaltablemodel.h.

59  : tName(aTableName), iColumn(indexCol), dColumn(displayCol) {}

Functions

◆ 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 64 of file qsqlrelationaltablemodel.h.

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

65  { return dColumn; }

◆ indexColumn()

QString QSqlRelation::indexColumn ( ) const
inline

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

Definition at line 62 of file qsqlrelationaltablemodel.h.

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

63  { return iColumn; }

◆ isValid()

bool QSqlRelation::isValid ( ) const
inline

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

Definition at line 66 of file qsqlrelationaltablemodel.h.

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

67  { return !(tName.isEmpty() || iColumn.isEmpty() || dColumn.isEmpty()); }
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ tableName()

QString QSqlRelation::tableName ( ) const
inline

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

Definition at line 60 of file qsqlrelationaltablemodel.h.

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

61  { return tName; }

Properties

◆ dColumn

QString QSqlRelation::dColumn
private

Definition at line 69 of file qsqlrelationaltablemodel.h.

◆ iColumn

QString QSqlRelation::iColumn
private

Definition at line 69 of file qsqlrelationaltablemodel.h.

◆ tName

QString QSqlRelation::tName
private

Definition at line 69 of file qsqlrelationaltablemodel.h.


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