Drivers not available in QT and PostgreSQL

0

I am trying to make a connection using QT to a PostgreSQL database. The code I was using is the following:

#include <QCoreApplication>

#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>

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

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("19x.xxx.xx.xx");
    db.setDatabaseName("baseDatos");
    db.setPort(5432);
    db.setUserName("usuario");
    db.setPassword("contra");

    bool ok = db.open();

    if(ok) qDebug() << "Conectado";
    else "No se pudo conectar";


    return a.exec();
}

However, when executing the program you get the following:

QSqlDatabase: QPSQL driver not loaded

QSqlDatabase: available drivers:

I am using PostgreSQL 10 and QT 5.8. How could I include those drivers? Thanks

    
asked by Adrian 29.11.2017 в 13:08
source

0 answers