[Qt-interest] Using true database cursors with Qt
Robert Hairgrove
evorgriahr at hispeed.ch
Thu Nov 26 13:01:26 CET 2009
John Moran wrote:
> Hello,
>
> I'm working on an application where I read an SQL query that returns
> binary strings (that are actually images, ultimately converted to
> QIcon) , which I use to populate a QStandardItemModel. I'm using
> PostgreSQL 8.3 as my database, and Qt 4.5. The Qt docs don't make it
> clear if Qt has a cursor API, through which we can use native database
> cursors and solve the problem of "impedance mismatch", which is likely
> to be acute if my user has lots of images - the interface will freeze
> for a disconcerting few seconds.
>
> Should I just use SQL to use cursors? Most database APIs I've used
> support native cursors directly, so this is a notable omission.
>
> Regards,
> John Moran
I believe that QSqlQuery provides exactly the same functionality as a
cursor. There might be some things you could do to improve performance
on the database side of things, though:
(1) proper indexing;
(2) fetch pre-built thumbnails instead of entire full-sized images to
populate your list;
(3) call QApplication:;processEvents() within your loop which should
help keep the GUI responsive.
Maybe you could show an example of how you are currently doing it?
More information about the Qt-interest-old
mailing list