[Qt-qml] QT 4.7 QSqlDatabase: QMYSQL driver not loaded

Chandraprakash Sharma envy.cp at gmail.com
Thu Aug 5 08:37:17 CEST 2010


Although this problem is not specific to QML but my application is QML
application in which I am getting error, based on qt4.7 beta2.

 QSqlDatabase defaultDB = QSqlDatabase::addDatabase("QMYSQL");
    defaultDB.setDatabaseName( "*******" );
    defaultDB.setUserName( "***********" );
    defaultDB.setPassword( "***********" );
    defaultDB.setHostName( "***********" );

    if ( defaultDB.open() ) {
        qDebug("Connected!");
        //Database successfully opened; we can now issue SQL commands.
        return true;
    }
    else
        return false;

Above is the code to connect to database, but I am getting the error

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE

After that I have tried installing mysql driver from source

but when doing qmake in qt/src/plugins/sqldrivers/mysql,

qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib
-lmysqlclient_r" mysql.pro

I am getting the error
qt_config.prf:7: include(file) requires one argument.

I am not being able to get it working, if someone can help then thanks!

Regards
CP



More information about the Qt-qml mailing list