View Single Post
Posts: 141 | Thanked: 41 times | Joined on Apr 2011 @ Ahmedabad, India
#2
Can you run the below code to verify that the required drivers are installed ?

#include <QCoreApplication>
#include <QSqlDatabase>
#include <QSqlError>
#include <QStringList>
#include <QtDebug>
int main( int argc, char **argv )
{
QCoreApplication app( argc, argv );
qDebug() << QSqlDatabase::drivers();
QSqlDatabase db( QSqlDatabase::addDatabase( "QMYSQL" ) );
qDebug() << db.lastError();
}

If the output of this code shows that drivers are installed, then make sure you create QApplication or QCoreApplication instance before you use classes from the QtSql module.

If the instance is created at a later stage, then also it throws such errors