[Qt-interest] QSqlite Table not showing all rows in app

Scott Aron Bloom scott at onshorecs.com
Tue Feb 9 05:40:58 CET 2010


I suggest you DONT call the fetchMore...  Its a major memory hog to do  
so...

Unless you need all the columns of all the rows, there is no reason  
to...  Dont forget the QSqlTableMode is acting as an interface between  
your views and the QSqlQuery...  So when you do a fetchMore, you are  
loading into memory, the complete database results.

Working just on the QSqlQuery, will have a LOT less overhead for non  
View related items, without any memory overhead.

Scott
On Feb 8, 2010, at 5:39 PM, William Lugg wrote:

> That was the ticket. I had looked at the help for QSqlTableModel and  
> completely overlooked the fetchMore and canFetchMore methods. for my  
> situation, I believe a while loop in the constructor to retrieve the  
> rest of the records will solve the problem. I suspected it was  
> something like this but couldn't find the key to unlock the problem.
>
> Thanks for the help.
> ----
> Bill Lugg
> Milstar Software Support
> Peterson AFB, CO
> No Micro$oft products were used to create this email.
> God rules and if He needed a computer it would run Linux!
>
> On Monday 08 February 2010 05:10:29 pm Scott Aron Bloom wrote:
> > I haev found that the rowCount() does NOT contain all the rows as  
> long
> > as the canFetchMore returns true. The model only loads 250 rows or  
> so
> > into memory at a time.
> >
> > One way to find all the rows...
> >
> > QSqlQuery query = model->query();
> >
> > query.last();
> > int numRows = query.at();
> >
> > Scott
> >
> > On Feb 8, 2010, at 3:54 PM, William Lugg wrote:
> > > I'm sure this would work, but it seems to defeat the whole MVC
> > > design pattern offered by Qt. It also doesn't solve the problem of
> > > the QDataWidgetMapper and/or the model running out of records
> > > prematurely at 250 records.
> > >
> > > Any ideas as to why the QSqlTableModel is under reporting the size
> > > of the table would be greatly appreciated.
> > >
> > > Thanks.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100208/d563ca2d/attachment.html 


More information about the Qt-interest-old mailing list