[置顶] 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).

你可能感兴趣的:(mysql,manager,search,qt,download,library)