PDA

View Full Version : How to connect MySQL with QT



diego
27th May 2009, 05:34
Hi all.
I want to use QT and connect to mysql server.
I have a big problem and i really can not fix that.

Step :

I install Free QT SDK

I make a simple project.

in .pro file

QT += sql

Source file :


QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("127.0.0.1");
db.setDatabaseName("ytr");
db.setUserName("root");
db.setPassword("");
if (!db.open()) {
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());

After i run my project :

It appears me a message " QMYSQL driver can not loaded"
I try again with QMYSQL3, QMYSQL4... It show the same.

What problem with me ?

Thanks.
Diego