Qt がロードされていない QPSQL ドライバーを繰り返してみましたが、役に立ちませんでした。x64 Postgresql を使用し、Qt アプリケーションも x64 を使用しました
m_dataBase.addDatabase("QPSQL");
m_dataBase.setHostName(g_hostName);
m_dataBase.setPort(g_databasePort);
m_dataBase.setDatabaseName(g_databaseName);
m_dataBase.setUserName(g_userName);
m_dataBase.setPassword(g_password);
qInfo() << "drivers:" << m_dataBase.drivers();
if( !m_dataBase.isDriverAvailable("QPSQL")) {
qWarning() << "Driver QPSQL is not available";
} else {
qInfo() << "QPSQL is available";
}
if (m_dataBase.open()) {
qInfo() << "Data base open SUCCESSFUL";
return true;
} else {
qWarning() << "Data base does not open";
qInfo() << "Last ERROR:" << m_dataBase.lastError().driverText();
}
有効にしました
qputenv("QT_DEBUG_PLUGINS", "1");
エディションのデバッグ ログ用。cmdでPATH変数を更新します
SET PATH=D:\PostgresLib\lib;%PATH%
SET PATH=D:\PostgresLib\bin;%PATH%
出力に表示された後:
[06/05/2021 10:28:13.305] DBG line: QFactoryLoader::QFactoryLoader() looking at "C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll"
[06/05/2021 10:28:13.306] WAR line: Found metadata in lib C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archreq": 0,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 393216
}
[06/05/2021 10:28:13.306] DBG line: Got keys from plugin meta data QList("QPSQL")
[06/05/2021 10:28:13.306] DBG line: QFactoryLoader::QFactoryLoader() checking directory path "D:/Projects/Build/sqldrivers" ...
[06/05/2021 10:28:13.309] DBG line: loaded library "C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll"
[06/05/2021 10:28:13.309] INF postgresdatabase.cpp virtual bool PostgresDataBase::init() line:24 drivers: QList("QSQLITE", "QODBC", "QPSQL")
[06/05/2021 10:28:13.309] INF postgresdatabase.cpp virtual bool PostgresDataBase::init() line:29 QPSQL is available
[06/05/2021 10:28:13.309] WAR postgresdatabase.cpp virtual bool PostgresDataBase::init() line:36 Data base does not open