QPSQL driver not loaded Qt(QPSQL 驱动未加载 Qt)
问题描述
我在添加数据库时遇到了一些麻烦.
_dataBase = QSqlDatabase::addDatabase("QPSQL");调用此方法后出现错误:
QSqlDatabase:未加载 QPSQL 驱动程序QSqlDatabase:可用驱动程序:QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7我包括到 PATH 变量路径:
PostgreSQL9.3inPostgreSQL9.3libPostgreSQL9.3包括我也将文件夹 sqldrivers 复制到 Debug 文件夹.还尝试将此文件夹中的 dll 复制到 Debug.也不行.
我来这里谷歌搜索是因为我在 Windows 中遇到了同样的问题.
就我而言,为了解决这个问题,我必须为 Windows 32 位安装 PostgreSQL,因为我的 Qt 目标是 MinGW 32 位.
此外,我必须将 PATH 添加到 PostgreSQL bin 和 lib 目录中,以便 Qt 可以找到正确的 .dlls.
@SET PATH=C:Program Files (x86)PostgreSQL9.6in;C:Program Files (x86)PostgreSQL9.6lib;%PATH%PATH 可以在启动 Qt Creator 之前设置,也可以通过 Projects 窗格中的 Build Environment 使用 Qt Creator 本身.>
I have some trouble when I want to add a database.
_dataBase = QSqlDatabase::addDatabase("QPSQL");
After calling this method I have an error:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I include to PATH variable paths to:
PostgreSQL9.3in
PostgreSQL9.3lib
PostgreSQL9.3include
Also I copy folder sqldrivers to Debug folder. Also tried to copy dlls drom this folder to Debug. Doesn't work either.
I came here googling because I had the same problem in Windows.
In my case to solve the issue I had to install PostgreSQL for Windows 32 bits since my Qt target was MinGW 32 bits.
Additionally, I had to add the PATH to the PostgreSQL bin and lib directories so Qt could find the right .dlls.
@SET PATH=C:Program Files (x86)PostgreSQL9.6in;C:Program Files (x86)PostgreSQL9.6lib;%PATH%
The PATH can be set before launching Qt Creator or using the Qt Creator itself via the Build Environment in the Projects pane.
这篇关于QPSQL 驱动未加载 Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:QPSQL 驱动未加载 Qt
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
