简体   繁体   English

如何配置Qt以使用SQLite?

[英]How to configure Qt to use SQLite?

I am very new to Qt and as well as Qt with database. 我对Qt以及数据库Qt都是新手。 Hope I get a positive response from you end. 希望我能收到您的积极回应。

I am using the code written in this forum for finding the Google drive folder path. 我正在使用在该论坛中编写的代码来查找Google驱动器文件夹路径。

I made a successful progress till building by solving all the errors. 通过解决所有错误,我在构建之前取得了成功的进展。 The build was successful, But while running I get the following error 构建成功,但是在运行时出现以下错误

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: 
Error in Opening  Google Drive db 

I know I missing somewhere the configuration of SQLite with Qt. 我知道我在某处缺少使用Qt的SQLite配置。 I just updated the pro file with Qt += sql 我刚刚用Qt += sql更新了pro文件

I can find the folders C:\\Qt\\4.8.5.x64\\src\\3rdparty\\sqlite , C:\\Qt\\4.8.5.x64\\src\\plugins\\sqldrivers\\sqlite in my system. 我可以在系统中找到文件夹C:\\Qt\\4.8.5.x64\\src\\3rdparty\\sqliteC:\\Qt\\4.8.5.x64\\src\\plugins\\sqldrivers\\sqlite

How to make the QSqlDatabase to link to this folder? 如何使QSqlDatabase链接到此文件夹? Or is there any separate installation for SQLite need to done for this or the libraries provided by the Qt itself is enough to support the database operation. 还是为此需要针对SQLite进行任何单独的安装,或者Qt本身提供的库足以支持数据库操作。

I have googled a lot, but didn't get any answers. 我在Google上搜索了很多,但没有得到任何答案。 Please let me know the steps to configure the SQLite. 请让我知道配置SQLite的步骤。

Look at C:\\Qt\\4.8.5.x64\\plugins\\sqldrivers do you see there qsqlite4.dll ? 看一下C:\\Qt\\4.8.5.x64\\plugins\\sqldrivers ,您看到那里qsqlite4.dll吗?

If not, than you should compile Qt with parameter -plugin-sql-sqlite if it static build, and compile qsqlite plugin manually if it shared. 如果不是,那么如果它是静态生成的,则应该使用参数-plugin-sql-sqlite编译Qt,如果共享则手动编译qsqlite插件。

cd %QTDIR%\src\plugins\sqldrivers\sqlite.pro
nmake
nmake install
nmake clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM