Results 1 to 2 of 2

Thread: QSqlDatabase: QMYSQL driver not loaded

  1. #1
    Join Date
    Jan 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlDatabase: QMYSQL driver not loaded

    I am using Qt Creator 2.4.1 in windows . While connecting to the database ,I am getting the following error

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

    Following is the code snippet :
    Qt Code:
    1. QSqlDatabase db( QSqlDatabase::addDatabase( "QMYSQL") );
    2. db.setHostName( "localhost" );
    3. db.setDatabaseName( "testdb" );
    4.  
    5.  
    6. db.setUserName( "root" );
    7. db.setPassword( "password" );
    8.  
    9. if( !db.open() )
    10. {
    11. qDebug() << db.lastError();
    12. qDebug() <<QSqlDatabase::drivers() ;
    13. qFatal( "Failed to connect." );
    14. }
    15.  
    16. qDebug( "Connected!" );
    17. db.close();
    To copy to clipboard, switch view to plain text mode 

    Regards ,
    Prachi

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlDatabase: QMYSQL driver not loaded

    The QMYSQL driver is not listed among the available drivers. You need to build it for your Qt and compiler. See the SQL Database Drivers docs

Similar Threads

  1. QSqlDatabase: QMYSQL driver not loaded
    By onder in forum Newbie
    Replies: 12
    Last Post: 29th March 2017, 14:43
  2. Replies: 19
    Last Post: 29th March 2016, 08:38
  3. Need Help:QSqlDatabase: QMYSQL driver not loaded
    By i4ba1 in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2011, 18:39
  4. QSqlDatabase: QMYSQL driver not loaded
    By earthling in forum Qt Programming
    Replies: 13
    Last Post: 4th December 2010, 15:19
  5. Replies: 6
    Last Post: 28th April 2009, 06:58

Tags for this Thread

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.