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

Scott Aron Bloom scott at onshorecs.com
Wed Feb 10 03:18:06 CET 2010


If you wanted a "slotGotoLast()" you would then yes use your  
fetchMore() loop

Scott
On Feb 9, 2010, at 5:18 PM, William Lugg wrote:

> Bear with me, I'm new to this...
>
> So If I understand you correctly, I should use your suggestion to  
> get to total record count. Then in my next record slot I should use  
> the fetchMore method when I get to the last record in the current  
> batch (assuming canFetchMore is true), right?
>
> Now, for the last record slot, on the surface it seems like I would  
> retrieve all the records, but as you said, I'd take a memory hit for  
> it. What would be a better approach while sticking within the MVC  
> design paradigm?
>
> 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 09:40:58 pm Scott Aron Bloom wrote:
> > 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
>
> _______________________________________________
> 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/20100209/713eb105/attachment.html 


More information about the Qt-interest-old mailing list