[Qt-interest] Showing a "Please wait" dialog during sql query
Scott Bloom
scott.bloom at onshorecs.com
Tue Jun 8 17:22:28 CEST 2010
The problem is not the population of the model. Its the blocking
QSqlQuery::exec call, which depending on the complexity can take a
significant amount of time.
In fact the model is quite smart about using a lazy population, and is very
very fast from the time you go setQuery on the model till the GUI updates.
Scott
On 6/8/10 1:49 AM, "Jan" <janusius at gmx.net> wrote:
> Just guessing ...
> Maybe it is also possible (and easier) to call
> QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents)
> during the population of the model in order to display a progressdialog.
> Haven't tried it but I suppose you need a timer in a separate thread then.
>
> Jan
>
> Am 07.06.2010 19:31, schrieb Gillen Daniel:
>> Hi @all
>>
>> I have a massive problem here and don't seem to find a solution for it.
>>
>> I'm developping a database application based on a MySQL database and I
>> would need to display a "Please wait" dialog while
>> populating a QSqlQueryModel. The data from QSqlQueryModel gets displayed
>> in a widget in my main window, so I have to exec the query in my main
>> thread. The problem is that any dialog I open before querying the data
>> hangs as my query blocks the main thread.
>>
>> Does anyone has an idea on how I could solve this? I would need some
>> sort of 2nd thread which displays the dialog with his own event loop but
>> as far as I understand, Qt does not support GUI interaction in a second
>> thread. Or is it perhaps possible to exec the query in a second thread
>> and then move the whole QSqlQueryModel and database connection to my
>> main thread?
>>
>> Thx in advance
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list