QPSQL driver not loaded Qt
Solution 1
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
.
@SET PATH=C:\Program Files (x86)\PostgreSQL\9.6\bin\;C:\Program Files (x86)\PostgreSQL\9.6\lib\;%PATH%
The PATH
can be set before launching Qt Creator or using the Qt Creator itself via the Build Environment
in the Projects
pane.
Solution 2
Use depends.exe on qsqlpsql.dll
and found that this dll need libpq.dll
from PostgreSQL\9.3\lib
folder. Add libpq.dll
to Debug
folder and it works:)

bin-bin
Updated on July 05, 2022Comments
-
bin-bin 11 months
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
toDebug
folder. Also tried to copy dlls drom this folder toDebug
. Doesn't work either.