Hey all

I have a problem with mysql connection. When i try to connect to a mysql database i get the error "driver not loaded".

I use the following code:
Qt Code:
  1. #include <QApplication>
  2. #include <QLabel>
  3. #include <QSqlDatabase>
  4. #include <QSqlError>
  5. #include <QMessageBox>
  6.  
  7. bool createConnection()
  8. {
  9. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  10. db.setHostName("***********");
  11. db.setPort(3306);
  12. db.setDatabaseName("wachtrij");
  13. db.setUserName("root");
  14. db.setPassword("");
  15. if (!db.open()) {
  16. QMessageBox::critical(0, QObject::tr("Database Error"),
  17. db.lastError().text());
  18. return false;
  19. }
  20. return true;
  21. }
  22.  
  23.  
  24. int main(int argc, char *argv[])
  25. {
  26. QApplication app(argc, argv);
  27. QLabel *label = new QLabel;
  28. if(createConnection() != false)
  29. {
  30. label->setText("Database connected");
  31. }
  32. else
  33. {
  34. label->setText("Database failed to connect");
  35. }
  36. label->show();
  37. return app.exec();
  38.  
  39. }
To copy to clipboard, switch view to plain text mode 

I had a problem with compiling the code but that is solved.
I followed these instructions: http://wiki.qtcentre.org/index.php?t...ws_using_MinGW
and when i want to compile i ad QT += sql to the .pro file

I've searched trough this forum and other forums but couldn't find the solution.

I am using Qt 4.3 and mingw on windows xp

I hope you can help me.