摘要: QDataWidgetMapper將一個數據庫記錄字段反映到其映射的窗口部件中,同時將窗口部件中所做出的更改反映回數據庫,關鍵是關聯一個model和一組widget
一、步驟
1、創建 QDataWidgetMapper 對象
2、關聯 model
3、關聯 widgets,并創建其與model中section的映射
4、定位到某個record
閱讀全文
摘要: 該類為單張的數據庫表提供了一個可編輯的數據模型,它支持外鍵,除此之外和QSqlTableModel沒有什么不同
閱讀全文
摘要: QSqlTableModel類繼承至QSqlQueryModel類,該類提供了一個可讀寫單張SQL表的可編輯數據模型,功能:修改,插入,刪除,查詢,和排序
常用函數
QVariant headerData ( int section,Qt::Orientation orientation, int role = Qt::DisplayRole ) const 獲取水平頭或垂直頭標題
bool setHeaderData ( int section,Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) 設置水平頭或垂直頭標題
int rowCount ( const QModelIndex & parent= QModelIndex() ) const // 返回行數
int columnCount ( const QModelIndex &index = QModelIndex() ) co
閱讀全文
摘要: QSqlQueryModel類為SQL的結果集提供了一個只讀的數據模型,下面我們先利用這個類進行一個最簡單的操作.
閱讀全文