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[])
{
DB_test_Dialog w;
w.show();
return a.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
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[])
{
Widget w;
w.show();
return a.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
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");
a.addLibraryPath("path");
To copy to clipboard, switch view to plain text mode
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?
Bookmarks