Recently I have installed Zorin os and qt creator from [enter link description here][1]
[1]: https://flathub.org. I need to connect the lamp server which I have installed. I am using qt creator and here is my sample code to connect the MySQL database.
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("csms");
db.setUserName("root");
db.setPassword("");
bool ok = db.open();
if(ok) {
qDebug() << "Database connected." << Qt::endl;
} else {
qDebug() << "Database connection error." << db.lastError ()<< Qt::endl;
}
But failed. I am googling the last two days but no luck. Now I am here. I need help.