经过model->rowCount();只能返回最多256个数据的长度的问题解决

在使用QT的QSqlQueryModel操做SQLite数据库的时候,经过model->rowCount();只能返回最多256。这个问题须要经过在操做结果前先经过fetchmore()来获取全部的结果,而后得到具体的行数。数据库

         QT的QSqlQuery或QSqlQueryModel每次最多只能缓存查询结果的256条。若是查询语句操做的结果超过256条了,也只能返回256。这样就必然会致使在后续操做中的错误。缓存

     解决方法以下:fetch

1.    while(model->canFetchMore())  it

2.      {  model

3.          model->fetchMore();  bug

4.      }  方法

5.      数据

6.     for(int i = 0; i < model->rowCount(); i++)  查询

7.      while

8.     {  

9.      

10.      qDebug()<<model->data(model->index(i,0)).toString();  

11.    

12.   }  

相关文章
相关标签/搜索