This is my code for the main.ccp :
#include <QCoreApplication>
#include<QtSql>
#include<QtDebug>
#include<Iostream>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("bd_gdv");
db.setUserName("postgres");
db.setPassword("xxxxxxxx");
if (db.open())
{
qDebug() <<"DB Opened";
db.close();
}
else
{
qDebug() << db.lastError().text();
}
return a.exec();
}
This code gives me the following error, I have searched for information but it is not clear to me how it is that the drivers are loaded
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 "Driver not loaded Driver not loaded"