PDA

View Full Version : Raspberry (Jessie): QT5, MySQL



hgstoehr
11th March 2016, 08:34
Hi,
I installed Qt5 on my RaspberryPi (Rasbian Jessie) using:

sudo apt-get install qt5-default
sudo apt-get install libqt5svg5*
sudo apt-get install qttools5-dev

When I tried to compile and execute a tiný program to access a MySQL database using:

QString dbname;
dbname = "QtTestDB";

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName(dbname);
db.setUserName("root");
db.setHostName("localhost");
db.setPort(3306);
db.setPassword("raspberry");

if(!db.open()) {
ui->textEdit->setText("not open !");
}

I got the message:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE
QSqlQuery::exec: database not open

The same program worked fine on QT4

It looks as if there is no MySQL Support for Qt5 on the system.
Does anybody know how to fix this?

Thank you!

anda_skoa
11th March 2016, 09:45
On desktop Debian the package of the MySQL driver for QSql is called libqt5sql5-mysql

Cheers,
_

hgstoehr
11th March 2016, 10:03
Thank you for the quick reply.
I installed libqt5sql5-mysql and libqsqlmysql.so is installed in /usr/lib/arm-Linux-gnueabihf/qt5/plugins/
but the QMYSQL Driver is still not found!
What did I forget?

Thank you

anda_skoa
11th March 2016, 11:59
Hmm, the package dependencies should have ensured all libraries are there, but check with ldd on the plugin .so that it indeed has all the libs it needs.

You can also try setting the envionment variable QT_DEBUG_PLUGINS to a non-zero value and see if this gives you any more hints

Cheers,
_

hgstoehr
11th March 2016, 13:12
Thank you!
Setting QT_DEBUG_PLUGINS was a good idea!
So I found out that there was some mixture with QT4 which is/was also installed.
After reconfiguring and recompiling everything is working now!
Best wishes!