I've really tried searching for an answer to this common problem but I keep coming up with little that's relative to my situation. Added to the fact I've not used Qt since 2015.

I am trying to upgrade a MacOS desktop app I wrote back then under ver. 5.4. Surprisingly, that app is working still, even on Big Sur. My original Qt IDE installation has got damaged so I had to download a new one. I am using Desktop 5.9.9 clang 64 bit, installed with the maintenance tool.

I can see the libmysql plugins in the drivers subfolder, so I assume they are installed, but for whatever reason, they're not loading. The compiler is giving me hundreds of warning messages of deprecated classes (definition of copy constructor and assignment) which I'm ignoring for now until I get the driver loaded. I don't know if this is impacting the sql connection strings I'm passing to QsqlDatabase.

Qt Code:
  1. // Connect to Database
  2. qDebug() << "Library path:";
  3. qDebug() << QCoreApplication::libraryPaths();
  4. qDebug() << "Drivers:";
  5. qDebug() << QSqlDatabase::drivers();
  6. if (!QSqlDatabase::drivers().contains("QMYSQL"))
  7. {
  8. QMessageBox::critical(0, "Unable to load database", "This application needs the MySQL driver");
  9. return -1;
  10. }
  12. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  13. db.setHostName("");
  14. db.setDatabaseName("VnK_Budget");
  15. db.setUserName("vince");
  16. db.setPassword("vai001");
  17. bool ok = db.open();
  18. if (! ok)
  19. {
  20. QString str;
  21. int err=db.lastError().type();
  22. str.setNum(err);
  23. str = "Connection Error "+str;
  24. QMessageBox::critical(0, str,
  25. db.lastError().text(), QMessageBox::Ok);
  26. exit(err);
  27. }
To copy to clipboard, switch view to plain text mode 

This is the output:

Library path:
("/Users/[USER]/Qt/5.9.9/clang_64/plugins", "/Users/[USER]/Developer/build-VDB-Desktop_Qt_5_9_9_clang_64bit-Debug/VDB.app/Contents/MacOS")
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7