[Qt-interest] running QSqlQuery's in a worker thread?

Scott Aron Bloom Scott.Bloom at sabgroup.com
Fri Jun 5 21:19:08 CEST 2009


So here is my problem, Im working on an app, where an individual sql
query can take up to 10 seconds (sometimes longer if the system is
really getting hammered)..  

 

The problem is, the system is an inventory search system, so its "very"
open in the types of searches that can be done.   Sometimes, a search
cant take 2-3 minutes.

 

The problem of course, is that the GUI freezes while the SQL query is
being executed.

 

What I was thinking was something like this, and I wanted to know if
anyone has a better solution..

 

First, create a modal "Please Wait Dialog" (I might use QProgressDialog,
but it has to be modal)

Second, create a thread that "executes a QSqlQuery, pre-prepared.

The thread will emit a signal, that I will connect the GUI thread to,
that notifies it when sql query is finished executing.

 

Close the modal dialog, and return to the normal flow of things..

 

The other advantage of this, is I would be able to use a cancel button
to kill the thread if necessary based on user needs.. 

 

Ideas? Thoughts?

 

Thanks in advance


Scott

 

 

 

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


More information about the Qt-interest-old mailing list