View Full Version : Problem: "QSqlDatabase: QPSQL driver not loaded" (Windows OS)

3rd May 2009, 21:00
Hi, I have the following problem trying to connect to a PostgresSQL database with PostgreSL 8.3:

Starting C:/Users/Alberto/Desktop/qttest/test1/debug/test1.exe...
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

In linux (ubuntu) it works, but not in Windows. I've googled a lot and actually I've found some "solutions", the problem is that I don't know how to carry out them. Anyway most of those solutions didn't really work, cause threads just ended up opened (with no final solution).

The solution appears to be nice is the one explained in this post (only 5 short replies):


And it's the following (if I've understood it right):

1. Use Dependency Walker with X (don't know how to use it, or the file I have to use it with)
2. Copy X .dll files into the folder where the executable is placed (don't know which .dll files exactly)

So the problem is that I don't understand it, or just don't know what do I have to do exactly. ¿Could any of you please guide me with this issue?.

Additional data that may be useful:
- Qt version: Qt 4.5.1 (the current newest one: qt-sdk-win-opensource-2009.02.exe, it also includes Qt-Creator 1.1.0 and MinGW 5.1.4)
- OS: Windows Vista
- PostgreSQL version: 8.3.7

Thanks in advance,


4th May 2009, 00:08
In general it means that you don't have QPSQL driver which is needed for connecting to PostgreSQL. For more information look here: http://doc.trolltech.com/4.5/sql-driver.html#qpsql-for-postgresql-version-7-3-and-above. There is also link at the end of that part: Compiling PostgreSQL On Native Win32 FAQ (http://www.postgresql.org/docs/faqs.FAQ_MINGW.html).

4th May 2009, 07:39
try to search by forum, this question was discussed many times.

4th May 2009, 09:44
Oks, thanks, I'll try those webs, faldżip. If I get blocked I'll continue searching in the forum. And if I don't solve the problem I'll ask again =).

10th November 2009, 20:48
Hi, I landed on this problem myself. I'm on windows and there is a special warning I would like to share with newbies like me:
if you want to compile the Postgresdriver for windows and you have installed Postgres on
c:\program files\Postgres\8.4
then the space in the path means you cant just modify the example suggested in the Qt documentation by simple substitution.
In other words the following call to qmake will not work
qmake "INCLUDEPATH+=C:\Program Files\PostgreSQL\8.4\include" "LIBS+=C:\Program Files\PostgreSQL\8.4\lib\libpq.lib" psql.pro
One way of getting around the problem is to
fix the makefile which contains the following incorrect assignments inside the definition of
-I"c:\Program" -I"Files\PostgreSQL\8.4\include"
replace these by
-I"c:\Program Files\PostgreSQL\8.4\include"

I dont know about doubling up the double quotes inside the strings ,maybe that's a better solution! In any case the user should be warned.