QSqlTableModel 绑定表

最后更新于:2022-04-02 02:14:42

[TOC] ## 实例 ### 绑定到QTableView ``` QSqlTableModel *model = new QSqlTableModel(parentObject, database); model->setTable("employee"); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->select(); model->setHeaderData(0, Qt::Horizontal, tr("Name")); model->setHeaderData(1, Qt::Horizontal, tr("Salary")); QTableView *view = new QTableView; view->setModel(model); view->hideColumn(0); // don't show the ID view->show(); ```
';