摘要: QDataWidgetMapper將一個(gè)數(shù)據(jù)庫記錄字段反映到其映射的窗口部件中,同時(shí)將窗口部件中所做出的更改反映回?cái)?shù)據(jù)庫,關(guān)鍵是關(guān)聯(lián)一個(gè)model和一組widget
一、步驟
1、創(chuàng)建 QDataWidgetMapper 對(duì)象
2、關(guān)聯(lián) model
3、關(guān)聯(lián) widgets,并創(chuàng)建其與model中section的映射
4、定位到某個(gè)record
閱讀全文
摘要: 該類為單張的數(shù)據(jù)庫表提供了一個(gè)可編輯的數(shù)據(jù)模型,它支持外鍵,除此之外和QSqlTableModel沒有什么不同
閱讀全文
摘要: QSqlTableModel類繼承至QSqlQueryModel類,該類提供了一個(gè)可讀寫單張SQL表的可編輯數(shù)據(jù)模型,功能:修改,插入,刪除,查詢,和排序
常用函數(shù)
QVariant headerData ( int section,Qt::Orientation orientation, int role = Qt::DisplayRole ) const 獲取水平頭或垂直頭標(biāo)題
bool setHeaderData ( int section,Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) 設(shè)置水平頭或垂直頭標(biāo)題
int rowCount ( const QModelIndex & parent= QModelIndex() ) const // 返回行數(shù)
int columnCount ( const QModelIndex &index = QModelIndex() ) co
閱讀全文
摘要: QSqlQueryModel類為SQL的結(jié)果集提供了一個(gè)只讀的數(shù)據(jù)模型,下面我們先利用這個(gè)類進(jìn)行一個(gè)最簡單的操作.
閱讀全文
摘要: QT:數(shù)據(jù)庫總結(jié)(一)
閱讀全文
摘要: [原創(chuàng)]QT筆記:給QTableWidget添加自定義標(biāo)題...待完善
閱讀全文
摘要: Qt下XML文檔的讀、寫(DOM方式)
閱讀全文