Correct way to use QSqlQueryModel in the different thread. How?
-
Hello all!
How to use QSqlQueryModel in the different thread correctly?
I have DB that is in different thread (worker schema/service schema) and it's working perfectly when I am using with QSqlQuery. How to implement the QSqlQueryModel that is preforming all DB requests in another thread? -
Hello all!
How to use QSqlQueryModel in the different thread correctly?
I have DB that is in different thread (worker schema/service schema) and it's working perfectly when I am using with QSqlQuery. How to implement the QSqlQueryModel that is preforming all DB requests in another thread?@bogong said in Correct way to use QSqlQueryModel in the different thread. How?:
How to use QSqlQueryModel in the different thread correctly?
You can't.
-
@bogong said in Correct way to use QSqlQueryModel in the different thread. How?:
How to use QSqlQueryModel in the different thread correctly?
You can't.
@kshegunov Do you know the reason of it? Is there something special of why it not possible? Or it's just not developed?
-
The reason is that you can't modify gui elements from another thread than the main thread.
-
@kshegunov Do you know the reason of it? Is there something special of why it not possible? Or it's just not developed?
What @Christian-Ehrlicher wrote, but more specifically, to have a query in a thread the
QSqlQuery
object must be created and accessed only from that thread, and even then the model can't be moved to worker, because the views (which are GUI objects) are not designed to handle it.