[Qt-interest] Showing a "Please wait" dialog during sql query
Linos
info at linos.es
Tue Jun 8 17:58:35 CEST 2010
i am creating the connection to the database and the query inside the thread,
more specifically i create an QObject subclass that i call Worker in the QThread
run method and in Worker i create the database connection, in every call for
execute a query the Worker class create a new query with his database connection
and execute the query, when the query has finished i emit the QSqlQuery from
Worker to the QThread subclass and from the QThread subclass to the main gui
where i assign it to a QSqlQueryModel.
This shows the behavior described in the last email, the first query works
wonderfully, the second query breaks the first model and show the results of the
last query. I can attach the python module i use for this if any want to see, i
have had not time to try other options but i would like to avoid have to make an
special model to work with the record of every row or the variant of every
column for every row.
Miguel Angel.
El 08/06/10 17:25, Scott Aron Bloom escribió:
> The problem is, the ownership and affinety of the QSqlQuery must be the same
> as the QSqlDatabase (This from Bill King of Nokia who is the/one of Nokia's
> Qt database guys)
>
> So what I got working, is creating the QSqlDatabase and its connection
> inside the thread (during the run phase), running the exec and emitting a
> signal when finished.
>
> Once its finished, then you can use the QSqlQuery from the other thread
> safely.
>
> Note, I have NOT tried modifying the QSqlQueyrModel, I would expect that if
> you got the QSqlRecord from the thread it would be ok..
>
> Scott
>
>
> On 6/8/10 1:16 AM, "Linos" <info at linos.es> wrote:
>
> > I am using something like this with pyqt, the only difference it is
> that i
> > emit
> > the QSqlQuery in a signal when the query has finished instead of
> return it
> > from
> > a method, but when later i execute other query in the same sql
> QThread with a
> > new created QSqlQuery in the same QSqlDatabase connection of the
> thread, the
> > first model get corrupted and gets the values of the last query.
> >
> > Miguel Angel
> >
> > El 08/06/10 07:53, Scott Bloom escribió:
> >> It got stripped.. My sent items has it attached...
> >>
> >> It was/is a zip file...
> >>
> >> Scott
> >>
> >>
> >> On 6/7/10 10:23 PM, "Andre Somers"<andre at familiesomers.nl> wrote:
> >>
> >>> Op 8-6-2010 0:22, Scott Aron Bloom schreef:
> >>>> I have attached a working solution. Its not fully vetted, so bugs
> >>>> probably exist :) but it works in the case shown...
> >>>>
> >>>>
> >>> Unfortunately, you have attached nothing...
> >>>
> >>> André
> >>>
> >>> _______________________________________________
> >>> 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
> >
>
More information about the Qt-interest-old
mailing list