[Qt-interest] QSqlite Table not showing all rows in app
William Lugg
wlugg at prairienetworks.com
Tue Feb 9 00:54:52 CET 2010
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.
----
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 Saturday 06 February 2010 07:32:05 pm you wrote:
> Since we are top posting, I don't use qt but my sql code would be:
> 'SELECT count(*) FROM tablename' to get the number of rows...
>
> William Lugg wrote:
> > Sorry, I should have included this info. I'm using a QSqlTableModel.
> > Here is the line of code I use to report the total rows in the model:
> >
> > QString strRecordCount = " of "
> > + QString::number(
> > memberDataModel->rowCount() );
> >
> > I use a QDataWidgetMapper to map data to widgets. I use
> > QDataWidgetMapper::toLast() and QDataWidgetMapper::toNext() to move
> > forware in the code in the following way:
> >
> > // If we're not at the last record, move to the next record
> > if ( memberDataMapper->currentIndex() < memberDataModel->rowCount() )
> > {
> > memberDataMapper->toNext();
> > setRecordCounter();
> > }
> >
> > member_data_entry::setRecordCounter() looks like this:
> > void member_data_entry::setRecordCounter()
> > {
> > ui->txtRecordNum->
> > setText( QString::number( memberDataMapper->currentIndex() ) );
> > return;
> > }
> >
> > It returns 255 when I'm on the "last" record, which makes sense given
> > zero- based counting, but doesn't make sense given that there are 3100
> > records in the table.
> >
> > Any help would be greatly appreciated.
> > ----
> > 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 Saturday 06 February 2010 02:50:31 pm Robert Wood wrote:
> >> William Lugg wrote:
> >>> In the DB app I'm working on, when I query the model for the row count
> >>> it claims it only contains 256 rows, though SQLite and a GUI browser I
> >>> use to look at the DB both verify that there are actually upwards of
> >>> 3100 rows in the table. What do I need to do in my code to get at the
> >>> rest of the data?
> >>>
> >>> The problem is two fold - I need my record counter to report the total
> >>> number of records and I need to be able to navigate to those records
> >>> when the user wants to go there.
> >>
> >> Not sure how much sqllite differs from mysql, but how are you querying
> >> the size of the database? Can we have a peek at the relevant line of
> >> code please?
> >>
> >> This works for me in mysql in that it does return the number of rows in
> >> the table:
> >>
> >> QSqlQuery query;
> >> quint32 rows;
> >> QString queryString;
> >>
> >> queryString = "SELECT * FROM tablename"
> >> query.exec(queryString);
> >> rows = query.size();
> >> _______________________________________________
> >> 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/20100208/f1b20671/attachment.html
More information about the Qt-interest-old
mailing list