I recently upgraded to 2.0 from 1.3.1 and have no sql drivers on linux.
Specifically i am looking to use MySQL. Works fine in 1.3.1, but I try the following code in 2.0:
qDebug() << QSqlDatabase::drivers();
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
To copy to clipboard, switch view to plain text mode
I then get this result:
QSqlError(-1,
"Driver not loaded",
"Driver not loaded")
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlError(-1, "Driver not loaded", "Driver not loaded")
To copy to clipboard, switch view to plain text mode
In my sdk directory, there is no src directory to build the drivers. I did, however find the following directory:
qtcreator-1.3.85/bin/sqldrivers
Here there was an existing libqsqlite.so
I downloaded the src code for qt 4.6.3, built the mysql driver successfully, and copied it to this folder, but to no avail.
I've changed to qt version inside the previous version of creator (1.3.1) to every version of qt that i have installed: 4.6.3 and 4.7.0 beta. Run a rebuild and it runs just fine, with the following code and response:
#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
return a.exec();
}
#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "sql drivers" << QSqlDatabase::drivers();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
response:
sql drivers ("QSQLITE", "QMYSQL3", "QMYSQL")
sql drivers ("QSQLITE", "QMYSQL3", "QMYSQL")
To copy to clipboard, switch view to plain text mode
My question is then, where is the new version of qtcreator looking for these driver files? And, more importantly, how do i get the new version running with sql support.
Bookmarks