Results 1 to 8 of 8

Thread: How to load Mysql driver?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default How to load Mysql driver?

    I am sorry for posting this question but can someone explain me how can I load the QMYSQL driver into my application?
    Qt Code:
    1. QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL")
    To copy to clipboard, switch view to plain text mode 
    gives me the following errors:

    Qt Code:
    1. QSqlDatabase: QMYSQL driver not loaded
    2. QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to load Mysql driver?

    Please post a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to load Mysql driver?

    I used a simple structure just to test if it is working with QMainWindow.
    Added menu items on menu, and on "triggered" open the database connection

    Qt Code:
    1. #include "default.h"
    2. #include "ui_default.h"
    3. #include <QtSql/QSql>
    4. #include <QtSql/QSqlDatabase>
    5. #include <QtSql/QSqlDriver>
    6. #include <QtSql/QSqlQuery>
    7. #include <QLayout>
    8.  
    9. default::default(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::default)
    12. {
    13. ui->setupUi(this);
    14. }
    15.  
    16. default::~default()
    17. {
    18. delete ui;
    19. }
    20. void default::on_actionSetari_Baza_de_Date_triggered()
    21. {
    22. QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL");
    23. db.setHostName("localhost");
    24. db.setDatabaseName("db");
    25. db.setUserName("user");
    26. db.setPassword("password");
    27. db.open();
    28. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to load Mysql driver?

    This is not a compilable example. Please post a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt Creator App launched by run option does not load mysql driver
    By l0ud in forum Qt Tools
    Replies: 0
    Last Post: 19th September 2012, 18:48
  2. cannot load mysql driver
    By saman_artorious in forum Qt Programming
    Replies: 1
    Last Post: 9th July 2012, 01:08
  3. source code for odbc driver or MySql driver in arm-embedded-linux
    By sattu in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th January 2011, 10:11
  4. I need MySQL driver for Qt 4.6, WindowsXP(32), MySQL 5.1
    By User_3 in forum Installation and Deployment
    Replies: 7
    Last Post: 15th October 2010, 15:19
  5. SQL driver load problem
    By vieraci in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2009, 14:59

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.