問題描述
我在添加數據庫時遇到了一些麻煩.
_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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!