Hello Everyone,

Well i am working on CentOS and trying to create a simple program which requires to connect with MySql.

Qt : 5
OS : CentOS

Qt Code:
  1. #include <QApplication>
  2. #include <QTableWidget>
  3. #include <QMessageBox>
  4. #include <QtSql>
  5.  
  6. int main(int argc,char* argv[])
  7. {
  8. QApplication app(argc,argv);
  9. QTableWidget* table = new QTableWidget();
  10. table->setWindowTitle("Connect to Mysql Database Example");
  11.  
  12. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  13. db.setHostName("192.168.11.3");
  14. db.setDatabaseName("menudb");
  15. db.setUserName("root");
  16. db.setPassword("test");
  17. if (!db.open())
  18. {
  19. QMessageBox::critical(0, QObject::tr("Database Error"),
  20. db.lastError().text());
  21. }
  22.  
  23. QSqlQuery query("SELECT * FROM test");
  24.  
  25. table->setColumnCount(query.record().count());
  26. table->setRowCount(query.size());
  27.  
  28. int index=0;
  29. while (query.next())
  30. {
  31. table->setItem(index,0,new QTableWidgetItem(query.value(0).toString()));
  32. table->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
  33. index++;
  34. }
  35.  
  36. table->show();
  37. return app.exec();
  38. }
To copy to clipboard, switch view to plain text mode 

Well the problem is MySql DRIVERS are not loaded.
Which drivers should i use in CentOS to connect my program with MySql?