QSqlRelation Class

The QSqlRelation class stores information about an SQL foreign key. 更多...

頭: #include <QSqlRelation>
qmake: QT += sql

公共函數

QSqlRelation (const QString & tableName , const QString & indexColumn , const QString & displayColumn )
QSqlRelation ()
QString displayColumn () const
QString indexColumn () const
bool isValid () const
void swap (QSqlRelation & other )
QString tableName () const

詳細描述

QSqlRelation is a helper class for QSqlRelationalTableModel 。見 QSqlRelationalTableModel::setRelation () 和 QSqlRelationalTableModel::relation () 瞭解細節。

另請參閱 QSqlRelationalTableModel , QSqlRelationalDelegate ,和 關係錶模型範例 .

成員函數文檔編製

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

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.

另請參閱 tableName (), indexColumn (),和 displayColumn ().

QSqlRelation:: QSqlRelation ()

Constructs an invalid QSqlRelation object.

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

另請參閱 isValid ().

QString QSqlRelation:: displayColumn () const

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

QString QSqlRelation:: indexColumn () const

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

bool QSqlRelation:: isValid () const

返迴 true QSqlRelation object is valid; otherwise returns false .

void QSqlRelation:: swap ( QSqlRelation & other )

交換 this with other .

QString QSqlRelation:: tableName () const

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