PDA

View Full Version : db driver not loaded



mak_user
3rd March 2011, 04:29
Hi,

I have to separate test projects with almost the same code. PostgreSQL driver is loaded in one of them only. Could You help me?

It is loaded here:


#include <QtGui/QApplication>
#include <QtSql>
#include <QMessageBox>

#include "dialog.h"


int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL7");
qDebug() << "DRIVERS :" << QSqlDatabase::drivers();

DB_test_Dialog w;
w.show();

return a.exec();
}


with this drivers
DRIVERS : ("QSQLITE", "QODBC3", "QODBC", "QPSQL7", "QPSQL")


and not loaded here:


#include <QtGui/QApplication>
#include <QtSql>
#include <QMessageBox>

#include "widget.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
qDebug() << "DRIVERS :" << QSqlDatabase::drivers();

Widget w;
w.show();

return a.exec();
}

with this message:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL3 QMYSQL
DRIVERS : ("QSQLITE", "QMYSQL3", "QMYSQL")

I use the same enviroment.

Added after 57 minutes:

OK. It is a path issue. Once I add
a.addLibraryPath("path"); I get all drivers and no error message issued.
I am using QT creator for building. Where can I set these paths? Why one of the test projects works correctly?

Lykurg
3rd March 2011, 05:25
Where is the QPSQL7 plugin located on your disk?