QSqlTableModel只能读取256个数据
QSqlTableModel每次最多只能缓存查询结果的256条。即,如果查询语句操作的结果超过256条了,也只能返回256。这样就会导致在后续操作中的错误。
解决方法如下:
tabModel = new QSqlTableModel(this,dsfQSLhelper.database);
tabModel->setTable("article"); //设置表
tabModel->select(); //选择表
//在操作结果前先通过fetchmore()来获取所有的结果
while(tabModel->canFetchMore())
{
tabModel->fetchMore();
}
qDebug()<<"tabModel->rowCount()"<<tabModel->rowCount();
qDebug()<<"columnCount()"<<tabModel->columnCount();