QSqlTableModel中removeColumn和removeColumns的区别

       QSqlTableModel类继承至QSqlQueryModel类,该类提供了一个可读写单张SQL表的可编辑数据模型,功能:修改,插入,删除,查询,和排序。

关于removeColumns函数的定义如下:

bool QSqlTableModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())

Reimplemented from QAbstractItemModel::removeColumns().

Removes count columns from the parent model, starting at index column.

Returns if the columns were successfully removed; otherwise returns false.

如下例:

model_sqltable->removeColumns(0,3);

意思即为移除从序列0开始的3列,即:0、1、2列共3列。

removeColumn函数


model_sqltable->removeColumn(0);        //作用是移除index为0的序列。

注意:

model_sqltable->removeColumn(0);

model_sqltable->removeColumn(1);

model_sqltable->removeColumn(2);

model_sqltable->removeColumns(0,3);

上述代码中,红色代码并不能代替绿色的代码的功能。

发布了39 篇原创文章 · 获赞 8 · 访问量 9200

猜你喜欢

转载自blog.csdn.net/cxd3341/article/details/100017341