时间:2021-07-01 10:21:17 帮助过:2人阅读
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");
}
Windows下Qt连接MySql数据库
标签: