Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Manjaro mariadb driver not loaded

Manjaro mariadb driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 560 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • saulosS Offline
    saulosS Offline
    saulos
    wrote on last edited by
    #1

    Hi to all,
    I'm new to Qt and I get this error trying to connect to my Mariadb server
    QSqlDatabase: test driver not loaded
    QSqlDatabase: available driver: QTBASE QSQLITE QMYSQL QMYSQL3 QODBC ...

    I use Manjaro, and I installed QTCreator, mariadb-connector-c
    I read also the tread for ARCH.
    I added this line to my test.pro
    QT += sql

    QTPLUGIN += qsqlmysql

    Is all corrected , any test unit I can look at ?
    Thanks

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @saulos said in Manjaro mariadb driver not loaded:

      QTPLUGIN += qsqlmysql

      This is not needed.
      You need to use 'QMYSQL' as database driver - please show us how you try to open the database.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • saulosS Offline
        saulosS Offline
        saulos
        wrote on last edited by
        #3

        Hi thanks for the reply.
        so I have to use
        QTPLUGIN += QMYSQL

        I got the example for a book and converted to Mariadb
        the code is :

        #include <QCoreApplication>
        #include <QtSql/QSql>
        #include <QtSql/QSqlDatabase>
        #include <QtSql/QSqlQuery>
        #include <QDebug>

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

        QSqlDatabase db = QSqlDatabase::addDatabase("test");
        db.setHostName("192.168.X.X");
        db.setPort(3306);
        db.setDatabaseName(("test"));
        db.setUserName("----");
        db.setPassword("----");
        if(db.open())
        {
            qDebug() << "Connesso";
        }
        else
        {
            qDebug() << "Fallita connessione";
            return 0;
        }
        
        return a.exec();
        

        }

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          RTM: https://doc.qt.io/qt-5/qsqldatabase.html#details

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • saulosS Offline
            saulosS Offline
            saulos
            wrote on last edited by
            #5

            Thanks
            Solved
            changed
            QSqlDatabase db = QSqlDatabase::addDatabase("test");
            to
            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved