标签:
1、设置环境变量,需添加如下的环境变量:
void UserData::Link()
{
QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");
db.setPort(3306);
db.setHostName("127.0.0.1");
db.setDatabaseName("chat");
db.setUserName("root");
db.setPassword("admin");
if(!db.open()){
qDebug()<<"Unable to open database";
}else{
qDebug()<<"Database connection established";
}
db.exec("SET NAMES GBK");
}
标签:
原文地址:http://www.cnblogs.com/tgycoder/p/5509943.html