How to make Qt aware of the QMYSQL driver

后端 未结 7 520
春和景丽
春和景丽 2021-01-12 04:26

I\'m trying to access a MySql database from a Qt application but I get the following error:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available dr         


        
7条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 05:00

    In order for your app to pick up the plugin at runtime, the shared library implementing the MySQL plugin needs to be placed in the correct directory. The best way of determining that directory is to check the output of QCoreApplication::libraryPaths. You can also force specific paths by using a qt.conf file.

    Please note that plugins must be placed in subdirectories within the plugin path, and the final part of the path name (i.e., the parent directory of the shared libraries) cannot be changed. SQL drivers need to go in a directory named sqldrivers, i.e. /sqldrivers. For more details on plugin directories, see How to Create Qt Plugins.

提交回复
热议问题