Qt例程之scooter

The QSqlTableModel class provides an editable data model for a single database table.

//爲單個數據庫表提供了可編輯的數據模型

void QSqlTableModel::setTable(const QString & tableName)
Sets the database table on which the model operates to tableName. Does not select data from the table,
but fetches its field information.
//設置模型操作的數據庫表,不會從表中選擇數據,獲取它的域信息

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

bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole)
Reimplemented from QAbstractItemModel::setHeaderData().
Sets the caption for a horizontal header for the specified role to value. This is useful if the model is used to display data
in a view (e.g., QTableView).
//爲特殊role的水平 header設置標題,爲特殊role,如果model用於在view中顯示數據

bool QSqlTableModel::select()
Populates the model with data from the table that was set via setTable(),
//使用從使用setTable()得到表的數據來填充model
using the specified filter and sort condition, and returns true if successful; otherwise returns false.
使用特定的過濾器和排序條件,成功就返回真

The QSqlDatabase class represents a connection to a database.

QSqlDatabase代表到數據庫的連接

QSqlDatabase QSqlDatabase::addDatabase(const QString & type, const QString & connectionName = QLatin1String( defaultConnection ))
Adds a database to the list of database connections using the driver type and the connection name connectionName. If there already
//使用驅動模式和連接名字添加數據庫到數據庫連接的列表.如果已經存在一個叫connectionName的數據庫連接,則連接會移除
exists a database connection called connectionName, that connection is removed.

void QSqlDatabase::setDatabaseName(const QString & name)
Sets the connection’s database name to name. To have effect, the database name must be set before the connection is opened.
//設置連接的數據庫名字爲,爲了有效,數據庫名字必須在連接打開前設置。
Alternatively, you can close() the connection, set the database name, and call open() again.
可選的是,你可以關閉連接,設置數據庫名字,再次調用open()

bool QSqlDatabase::open()
Opens the database connection using the current connection values.
//使用當前連接值來打開數據庫連接
Returns true on success; otherwise returns false. Error information can be retrieved using lastError().
//可以使用lastError()來獲取錯誤信息

The QSqlQuery class provides a means of executing and manipulating SQL statements

//提供了一種執行和操作的SQl語句方法

bool QSqlQuery::exec(const QString & query)
Executes the SQL in query. Returns true and sets the query state to active if the query was successful;
//在詢問中執行SQL,如果查詢是成功的,返回真和設置查詢狀態爲活動
otherwise returns false. The query string must use syntax appropriate for the SQL database being queried (for example, standard SQL).
//查詢字符串必須和SQL數據庫查詢的語法

void QAbstractItemView::setSelectionModel(QItemSelectionModel * selectionModel)
Sets the current selection model to the given selectionModel.
//設置當前選擇模式

selectionBehavior : SelectionBehavior
This property holds which selection behavior the view uses.
//view使用哪種選擇行爲
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)

void QTableView::setColumnHidden(int column, bool hide)
If hide is true the given column will be hidden; otherwise it will be shown.
//hide是真,給定的col會隱藏

void QTableView::resizeColumnsToContents()
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
//重置所有的col。基於 用於構造col的每個item的delegate 的大小提示

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