View Single Post
Posts: 2 | Thanked: 0 times | Joined on Jun 2011
#3
Originally Posted by dtparikh View Post
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
I get the following output

Code:
Killing remote process(es)...
Starting remote process ...
("QSQLITE") 
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE
QSqlError(-1, "Driver not loaded", "Driver not loaded") 
Killing remote process(es)...
Finished running remote process. Exit code was 0.