Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
requested database does not belong to the calling thread
nn26 last edited by
I am getting this error.
QSqlDatabasePrivate::database: requested database does not belong to the calling thread
In my application with database, I have 5 tables. I am using two tables with one thread (with plugins to application) and another three tables with second thread from same application.
is this a problem due to same connection name for both thread? or something else?
JonB last edited by JonB
You can only access a
QSqlDatabasefrom the thread which created it/in which it lives.
You need to create one connection per thread directly in the thread where you will use it.
nn26 last edited by nn26
QSqlDatabasePrivate::addDatabase: duplicate connection name'xxx', old connection removed
so this is creating problem right?
@nn26 Don't use same connection name more than once
Give each thread's connection a unique name. You can use the thread id for that for example.