Qt例程之staff

The QSqlRelationalTableModel class provides an editable data model for a single database table,
// 爲單個數據庫表提供了可編輯的數據model,提供外鍵支持
with foreign key support

void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime)
This function overloads processEvents().
Processes pending events for the calling thread for maxtime milliseconds or until there are no more events to process,
//爲調用的thread處理掛起的事件,或者直到沒有事件處理
whichever is shorter.

bool QSqlQuery::prepare(const QString & query)
Prepares the SQL query query for execution. Returns true if the query is prepared successfully; otherwise returns false.
//爲執行準備sql查詢,成功準備返回真

void QSqlQuery::bindValue(const QString & placeholder, const QVariant & val, QSql::ParamType paramType = QSql::In)
Set the placeholder placeholder to be bound to value val in the prepared statement. Note that the placeholder mark (e.g 😃
//爲value邊界設置佔位符,佔位符標記必須被包括,當直到佔位符名字時
must be included when specifying the placeholder name. If paramType is QSql::Out or QSql::InOut, the placeholder will be
overwritten with data from the database after the exec() call. In this case, sufficient space must be pre-allocated to store
the result into.

The QSqlRelation class stores information about an SQL foreign key
//存儲關於SQL外鍵的信息
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.
//構造一個QSqlRelation對象,tableName是外鍵參考的SQL表名字, indexColumn是外鍵,displayColumn是呈現給用戶的

void QSqlRelationalTableModel::setRelation(int column, const QSqlRelation & relation)
Lets the specified column be a foreign index specified by relation.
//讓指定的col爲一個由relation指定的外鍵索引

void QSqlTableModel::setSort(int column, Qt::SortOrder order)
Sets the sort order for column to order. This does not affect the current data, to refresh the data using the new sort order,
call select().
//爲col設置排序,不影響當前數據,爲更新使用新的排序的數據,使用select();

##The QSqlRelationalDelegate class provides a delegate that is used to display and edit data from a QSqlRelationalTableModel.

QSqlRelationalDelegate提供了delegate,用於顯示和編輯從QSqlRelationalTableModel來的數據

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章