QSqlDatabase: QMYSQL driver not loaded 解决方法

转自: 点击打开原文链接
虽然 已执行: sudo apt-get install libqt4-sql-mysql,但还是出现QSqlDatabase: QMYSQL driver not loaded
其实是驱动放的路径不对,应该放在 QtSDK/Desktop/Qt/473/gcc/plugins
如果没有找到libqsqlmysql.so文件,你可以下载下来,解压拷贝过去

sudo apt-get download libqt4-sql-mysql(下载命令)



Wednesday, September 21, 2011

Install Qt MYSQL Driver for Linux (Ubuntu).

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QSQLITE2

You might have come across this error, if you are using Qt SDK from Nokia.

Now follow these steps to get MYSQL working with Qt Creator.

Go to System-> Administration-> Synaptic manager and search " libqt4-sql-mysql" (libqt3-sql-mysql if you are using Qt3) and install the library by right clicking and select Mark for installation.



Now, in your Qt code add this line
                                qDebug() << QCoreApplication::libraryPaths();

You will see something like this upon running your program.
("/home/raja/QtSDK/Desktop/Qt/473/gcc/plugins", "/home/raja/Documents/QtProjects/SyncTest-build-desktop")

Now copy libqsqlmysql.so (search it or find it as shown in the above picture) to the above path. You can also use the library by using QCoreApplication::addLibraryPath(QString path).

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值