QSqlDatabase: QMYSQL driver not loaded 解决方法

来源:互联网 发布:淘宝上发票抬头写个人 编辑:程序博客网 时间:2024/04/30 14:35
转自:点击打开原文链接
虽然已执行: 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 usingQCoreApplication::addLibraryPath(QString path).

原创粉丝点击