[Solved] QThread and QSqlDatabase example
Is there any example/ reference for QThread + QSqlDatabase ?
I don't know will it be helpful but:
In one of my projects i use QTreadPool and QRunable task. In every task i create a copy of DB connection:
@QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
Thanks for the links , Can you provide an idea about the implementation, a basic skeleton will be sufficient.
I'll try. What is your goals, what you try to do?
I have a scenario where I am loading a QListView with many items from the database. So my requirement is to implement this using QThreads in such a way that the application does not freeze.
i have gone through the following links:
- "How To Really, Truly Use QThreads; The Full Explanation":http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
- "The great QThread Mess":http://www.christeck.de/wp/2010/10/23/the-great-qthread-mess/
- "You’re doing it wrong…":http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
- "Threads and QObjects":http://qt-project.org/wiki/ThreadsEventsQObjects#64a093776750c691afdeb133a80f55e2
I am still looking for a proper example.
Have you already got experience with qthreads? If yes you can use one global QSqlDatabase object with synchronization on access to it, or an QSqlDatabase for each thread.