I have installed the Qt version 5.15 for C++, but the drivers for MySQL didn't came with it, so i've been using SQLITE3 instead. I've searched on the internet how to do it, but in every website or youtube video the organization of the Qt files where completelly diferent from mine, so I dont know how to do it. I've downloaded the open source version of Qt5 using the online installer.
This is the code I've been trying to use
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("locahost");
db.setUserName("root");
db.setPassword("");
db.setDatabaseName("qt6");
if(db.open())
{
QMessageBox::information(this, "Connected", "Connected");
}
else
{
QMessageBox::information(this, "Not Connected", "Not Connected");
}
Of course the messagebox is always the error one and in the command line it says this:
17:28:18: Starting C:\Users\Ale Ghio\Desktop\QT\build-QTsql-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug\debug\QTsql.exe ...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
17:28:21: C:\Users\Ale Ghio\Desktop\QT\build-QTsql-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug\debug\QTsql.exe exited with code 0
How can I solve this problem?