title: Using QSqlDatabase connection in QtConcurrent::run (pseudo connection pooling)
body: <p>I'm trying to find an efficient way to handle some database queries in Qt. The scenario essentially is that we have many events that we need to write to the db. We cannot block the main thread while writing so these writes are done in separate threads using <code>QtConcurrent::run</code>.</p>
  
  <p>Now, the issue is that currently each concurrent run requires creating a new connection to the DB. We'd like to simply be able to create the connection once and reuse it, but the Qt docs state a connection may only be used in the thread that created it. Using QtConcurrent makes this quite problematic since we don't know in which thread we'll be run.</p>
  
  <p>Note that we have no interest in making writes to the database be parallel, that is, we can impose the restriction that only one thread uses the db connection at once.</p>
  
  <p>Is there any way to use one DB connection and still use QtConcurrent? Or do we, as I fear, have to use a QThread and implement our own signalling rather than making use of the concurrent framework?</p>
  
  <hr>
  
  <p><strong>Answer</strong>: The answers seem to indicate as I suspected, that it just can't be done. QtConcurrent and DB connections don't play well together. This is really too bad. I guess I'll just go back to creating my own thread and using custom signals and slots to communicate.</p>