[Interest] QSqlQuery

Andre Somers andre at familiesomers.nl
Sun Jan 26 20:02:21 CET 2014


Igor Mironchik schreef op 26-1-2014 16:29:
> Hi.
>
> I have some questions about database support in Qt 5.
>
> First of all, is it safe to transfer a QSqlQuery instance from one 
> thread to another to process him in another thread. I.e. I want to 
> execute SELECT query on "DB" thread and return a QSqlQuery from that 
> thread to the GUI thread, where I will navigate and show users the 
> result of the query.
>
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)

André

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140126/aceb69e1/attachment.html>


More information about the Interest mailing list