[Interest] QSqlQuery

Thiago Macieira thiago.macieira at intel.com
Sun Jan 26 20:52:09 CET 2014


On domingo, 26 de janeiro de 2014 22:24:58, Igor Mironchik wrote:
> > No, that is not safe. You can use database access from threads, but
> > every thread needs it own QSqlDatabase instance of the database
> > connection. The documentation states:
> > "A connection can only be used from within the thread that created it.
> > Moving connections between threads or creating queries from a
> > different thread is not supported."
> > (http://qt-project.org/doc/qt-4.8/threads-modules.html#threads-and-the-sql
> > -module)
> I will not use QSqlDatabase in another thread. I want to create
> QSqlDatabase connection in worker thread and execute queries in that
> thread... For SELECT statemetsa I want to return QSqlQuery object from
> worker thread to the GUI one. Is it safe to use QSqlQuery in another
> thread that created him?

Using QSqlAnything implies using the QSqlDatabase it's connected to. So you 
can't move QSqlQuery from one thread to another.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140126/c8cf092a/attachment.sig>


More information about the Interest mailing list