Answer the question
In order to leave comments, you need to log in
How can I safely use a QSqlDatabase connection from different threads?
I have a DB connection instance ( QSqlDatabase ). I also have a main form on which, for example, there is a button for selecting a user's picture. How can I properly organize the loading of this image into the database? Obviously, in this main thread, where I have a GUI, it is wrong to do this, because the program window may freeze, although in fact the program just loads the picture and the window is "waiting" at that time.
As I understand it, you need to do this in a separate thread, but somewhere in the Qt documentation it says that " a QSqlDatabase connection can only be used from the thread that created it ". There is also an option to use mutexes and a static declaration, but I don’t fully understand what and how.
Please tell me how to be.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question