Pertinent information up front:
Qt version: 4.0.0 open source
Build environment: Mingw on Windows XP SP2
PostgreSQL version: 8.0.3
In short, I wrote a short demo application to be able to retrieve SQL data from a PostgreSQL database using Qt. The problem is, my sample app refuses to load any SQL plugins of any kind. The Sqlbrowser demo application is able to load the plugin and even connect to the database and retreive data properly, yet my application cannot.
I get this message upon program execution:
|
Source code
|
1
2
3
|
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers:
Database connection not successful!
|
Here is the code for my app (all of the database settings are correct):
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <QtCore>
#include <QtSql>
#include <QSqlDatabase>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QSqlDatabase qdb = QSqlDatabase::addDatabase("QPSQL");
qdb.setHostName("localhost");
qdb.setDatabaseName("test");
qdb.setUserName("postgres");
qdb.setPassword("1234");
qdb.setPort(5432);
if(qdb.open())
{
cout << "Database connection successful!" << endl;
}
else
{
cout << "Database connection not successful!" << endl;
}
qdb.close();
return 0;
}
|
Here is my project file:
|
Source code
|
1
2
3
4
5
6
7
8
|
TEMPLATE = app
DEPENDPATH += .
QT += sql
CONFIG += qt console sql
# Input
SOURCES += main.cpp
|
Is there something I'm missing? I looked at the sqlbrowser source (as well as the project file) and it doesn't seem that it's doing anything drastically different from what I was doing (except for a GUI, but that should be independent of database stuff).
Any help would be appreciated.