QTableView中嵌入复选框CheckBox
设置QAbstractTableModel的flags()函数法
主要是修改两个函数:
//设置某一列为可选角色,绘画出QCheckBox
Qt::ItemFlags flags(const QModelIndex &index) const;
//根据界面选择QCheckbox,修改Model中的数据
- 2.在StudentInfoModel
.h头文件中的主要代码: - class
StudentInfoModel public: QAbstractTableModel - {
-
Q_OBJECT - public:
-
StudentInfoModel(const int totalColumn, constint aColumnNumWithChechBox = 0, QObject *parent = 0) -
:totalColumn(totalColumn),colNumberWithCheckBox(aColumnNumWithChechBox), -
-
QAbstractTableModel(parent) {rowCheckStateMap.clear();}; - public:
-
int rowCount( constQModelIndex const;&parent = QModelIndex()) -
int columnCount(