QSQLITE driver not loaded

  • Hi!
    I have problem with deployed application. It could not create and access sqlite database, with next messages in debugger:

    QSqlDatabase: QSQLITE driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    bool AnisStorage::setupDb() Error: "Driver not loaded Driver not loaded"
    QSqlQuery::exec: database not open

    And here is code example:

        m_dbConnection = QSqlDatabase::addDatabase("QSQLITE");
        // m_dbName = D:/QtBuilds/kvant-cpm-release/cpmStorage.sqlite
        const bool isDbOpened = m_dbConnection.open();
        if(!isDbOpened) {
            qDebug() << Q_FUNC_INFO << "Error:" << m_dbConnection.lastError().text();
            return false;

    I am using Qt 5.4.2, MinGW 4.9.2 and have "sqldrivers" dir with Qt SQL drivers in application folder.

    How to fix this?)

  • Hello

    I have the same problem. I use Qt 5.5 on Archlinux.

    This my codes:

    #ifndef STORAGE_H
    #define STORAGE_H
    #include <QObject>
    #include <QSqlDatabase>
    #include <QDebug>
    #include <QSqlError>
    #include <QSqlDriver>
    class QString;
    class Storage : public QObject
        explicit Storage(QObject *parent = 0);
        Q_INVOKABLE bool open();
    public slots:
        QSqlDatabase* m_sqlDatabase;
    #endif // STORAGE_H


    #include "storage.h"
    Storage::Storage(QObject *parent) : QObject(parent)
        m_sqlDatabase = new QSqlDatabase();
    bool Storage::open()
        qDebug() << QSqlDatabase::drivers();
        qDebug() << QSqlDatabase::isDriverAvailable("QSQLITE3");
        m_sqlDatabase->addDatabase("QSQLITE3", "SQLITE");
        if (m_sqlDatabase->open()){
            return true;
            qDebug() << m_sqlDatabase->lastError();
            return false;

    and my .pro

    unix:LIBS += -lpq -L"/usr/lib/qt/plugins/sqldrivers"

    As ExorcistInc, I have this messages with qDebug() :
    QSqlError("", "Driver not loaded", "Driver not loaded")

    Have I include other file ?

    Thank you in advance


  • Well, I figured out, that in my case it was stupid mistake of using MSVC windeployqt with MinGW compiled app.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.