Let's try to get this working
You only need #include <QtSql> because this will include all the others you mentionI am using Qt4.2 and MySql server version 5.0.83 in Ubuntu Karmic Koala. My header file has these includes:
Qt Code:
#include <QSqlDatabase> #include <qsqldatabase.h> #include <QSqlError> #include <QSqlQuery> #include <QtSql> #include <QMYSQLDriver> #include <QtSql/QMYSQLDriver>To copy to clipboard, switch view to plain text mode
You can delete this line, it doesn't do what you want or think it does. It returns the database with the name "connection-test", it does not set the connection name.The connection code is:
Qt Code:
To copy to clipboard, switch view to plain text mode
It tells you exactly what is wrong. The Qt MySql driver is not found.And what I get is a message called Database Error saying: Driver not loaded Driver not loaded
The Application Output is:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QSQLITE2 QPSQL7 QPSQL
You will need to build the driver and install it in the correct plug-in folder of your Qt installation.
Or, try your package manager to see if you can just download it.
Bookmarks