xampp Mysql connection using QT in Windows OS
i am having a problem in connecting xampp mysql and QT. Here is the code that i had found in the net but gives an error:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("sample_datebase");
db.setUserName("root");
db.setPassword("");
if(!db.open()) {
QSqlError err = db.lastError();
QMessageBox::information(0, QObject::tr("Error Connection!"), err.text(开发者_如何学C));
return 1;
}
the error message is:
Driver not loaded
Qt store all database-specific code within the drivers, such as QMYSQL driver. Compiled drivers are atored as a plugins. Before using plugins you need to build them with installed database libraries.
Detailed descriotion of how to build plugins for different databases under differen OS is described here.
精彩评论