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