Results 1 to 13 of 13

Thread: QSqlDatabase: QMYSQL driver not loaded

  1. #1
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSqlDatabase: QMYSQL driver not loaded

    hi,

    i am trying to connect mysql server bu i take this error :
    "QSqlDatabase: QMYSQL driver not loaded"

    i search forum and google i didnt find works answer.

    i am using linux and my qt version 4.2
    i install mysqlserver, mysqlclient and mysql libs.

    please help.

    thanks alot

    onder

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    How did you install Qt?

  3. #3
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    i am using pardus(linux distrubition).
    i use pardus packet manager and i install
    qt4
    qt-sql-mysql
    qt-doc

    but default qt files still there (qt3)

    onder

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    Quote Originally Posted by onder
    i use pardus packet manager and i install
    qt4
    qt-sql-mysql
    Are you sure that this qt-sql-mysql package if for Qt 4.2?

  5. #5
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    yes i checked :qt-sql-mysql for qt 4x

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    Try this:
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QSqlDatabase>
    3. #include <QStringList>
    4. #include <QtDebug>
    5.  
    6. int main( int argc, char **argv )
    7. {
    8. QCoreApplication app( argc, argv );
    9. qDebug() << QSqlDatabase::drivers();
    10. }
    To copy to clipboard, switch view to plain text mode 
    it should print all available drivers (don't forget about QT += sql).

    Make sure you create QCoreApplication or QApplication instance before you try to connect to the database.

  7. #7
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    hi ,
    i compile and run yopur code.
    its result

    ("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QPSQL7", "QPSQL")

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    And how about this?
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QSqlDatabase>
    3. #include <QSqlError>
    4. #include <QStringList>
    5. #include <QtDebug>
    6.  
    7. int main( int argc, char **argv )
    8. {
    9. QCoreApplication app( argc, argv );
    10. qDebug() << QSqlDatabase::drivers();
    11. QSqlDatabase db( QSqlDatabase::addDatabase( "QMYSQL" ) );
    12. qDebug() << db.lastError();
    13. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    ("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QPSQL7", "QPSQL")
    QSqlError(-1, "", "")

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    Quote Originally Posted by onder
    QSqlError(-1, "", "")
    So it seems to work and most probably the problem lies in your code. As I already wrote, make sure you create QApplication or QCoreApplication instance before you use classes from the QtSql module.

  11. The following user says thank you to jacek for this useful post:

    onder (15th August 2006)

  12. #11
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    hi,

    i understood but late understood.
    you are right : problem QApplication instance problem.
    thanks a lot

    Onder

  13. #12
    Join Date
    Mar 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    ("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    QSqlError("", "Driver not loaded", "Driver not loaded")
    Press <RETURN> to close this window...



    Hello, this is my console output whenever I run this code below:

    #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();
    }


    What could be the problem, please?
    Thanks in advance.
    I'm using Qt5.8
    Last edited by noka; 29th March 2017 at 14:28. Reason: updated contents

  14. #13
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    You have to install Mysql client. QMysql driver is only interface to standard Mysql client.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.