Qt连接MySQL出现QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase:QMYSQLdrivernotloaded QSqlDatabase:availabledrivers:QSQLITE 解决方法,先看下是否已经安装了libqsqlmysql.so [test1@localhost~]$locatelibqsqlmysql.so /var/cache/abrt-di/usr/lib/debug/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so.
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE
解决方法,先看下是否已经安装了libqsqlmysql.so
[test1@localhost ~]$ locate libqsqlmysql.so
/var/cache/abrt-di/usr/lib/debug/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so.debug
我的系统上还没有安装,下面安装 qt-mysql.i686。
[root@localhost test1]# yum install qt-mysql.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
qt-mysql i686 1:4.7.4-7.fc14 updates 67 k
[root@localhost test1]# updatedb
[test1@localhost ~]$ locate libqsqlmysql.so
/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so
/var/cache/abrt-di/usr/lib/debug/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so.debug
在程序里面调用
qDebug()QCoreApplication::libraryPaths ();
可以看到Qt 搜索库的路径。里面并没有/usr/lib/qt4/plugins/
这里有两种方式解决这个问题:
1、把libqsqlmysql.so所在的路径增加到库路径里面:
QcoreApplication::addLibraryPath("/usr/lib/qt4/plugins/");
2、直接复制libqsqlmysql.so到Qt的搜索路径中。
[test1@localhost ~]$ cp /usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so QtSDK/Desktop/Qt/4.8.1/gcc/plugins/sqldrivers/
http://doc.qt.nokia.com/4.7-snapshot/sql-driver.html
上一篇: PHP大量数据循环时内存耗尽问题的解决方案_PHP教程
下一篇: 【原创】PHP超时处理全面总结
推荐阅读
-
PyQt5连接MySQL及QMYSQL driver not loaded错误解决
-
qt连接mysql报错:QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
-
Qt连接MySQL出现QSqlDatabase: QMYSQL driver not loaded
-
CentOS7 (64位) 下QT5.5 连接MySQL数据库(driver not loaded)
-
Qt连接MySQL提示“QSqlDatabase: QMYSQL driver not loaded”的解决办法
-
QSqlDatabase:QMYSQL driver not load 之Qt与MySQL连接报错的解决办法
-
PyQt5连接MySQL及QMYSQL driver not loaded错误解决
-
qt连接mysql报错:QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7