hi,
I have trouble conneting to PostgreSQL database. With installed newest QTSDK I am working on linux platform with qt creator.
This is my code:
#include <QtGui/QApplication>
#include <QSqlDatabase>
#include <QMessageBox>
int main(int argc, char *argv[])
{
db.setDatabaseName("name");
db.setPassword("pass");
db.setHostName("localhost");
db.setUserName("user");
if (!db.open()) {
QMessageBox::warning(0, qApp
->tr
("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"));
return false;
}
return a.exec();
}
#include <QtGui/QApplication>
#include <QSqlDatabase>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setDatabaseName("name");
db.setPassword("pass");
db.setHostName("localhost");
db.setUserName("user");
if (!db.open()) {
QMessageBox::warning(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"));
return false;
}
return a.exec();
}
To copy to clipboard, switch view to plain text mode
I have added sql module in .pro file.
Connection isn't established.
Is it possible that there is problem with driver, because I read that this driver is supported in QT?
Could you help me?
Thanks
Added after 15 minutes:
Don't bother, I found the problem. It was connected to postgre configuration files.
Bookmarks