I have some trouble when I want to add a database.
_dataBase = QSqlDatabase::addDatabase("QPSQL");
After calling this method I have an error:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I include to PATH
variable paths to:
PostgreSQL\9.3\bin
PostgreSQL\9.3\lib
PostgreSQL\9.3\include
Also I copy folder sqldrivers
to Debug
folder. Also tried to copy dlls drom this folder to Debug
. Doesn't work either.
Use depends.exe on
qsqlpsql.dll
and found that this dll needlibpq.dll
fromPostgreSQL\9.3\lib
folder. Addlibpq.dll
toDebug
folder and it works:)I came here googling because I had the same problem in Windows.
In my case to solve the issue I had to install PostgreSQL for Windows 32 bits since my Qt target was MinGW 32 bits.
Additionally, I had to add the
PATH
to the PostgreSQL bin and lib directories so Qt could find the right.dlls
.The
PATH
can be set before launching Qt Creator or using the Qt Creator itself via theBuild Environment
in theProjects
pane.Try
pip install PyQt5
event if you already installed it using conda or installer. It helped me.Add the system variable
QT_DEBUG_PLUGINS=1
if you want to get full information of why theQPSQL
driver has not been loaded.Probably you will discover that Qt is not able to find it. Copy and paste the output here to know what exactly happens.