简体   繁体   English

QT-PostgreSQL插件错误

[英]QT - PostgreSQL plugin error

I have an app, that should connect to database. 我有一个应用程序,应该连接到数据库。 Under linux i've no problems, but under windows - > i've to add to system "Path" place, where QT enviroment is placed (C:/QT/Tools/QTCreator/bin) otherwise it doesn't work and shows errors like below. 在Linux下,我没有问题,但是在Windows下->我必须添加到系统“ Path”位置,并放置QT环境(C:/ QT / Tools / QTCreator / bin),否则它将不起作用并显示错误如下。 id doesn't work if i place exe file on pendrive too 如果我也将exe文件放在pendrive上,则id无法正常工作

i would like to send this app to my firends, who shouldn't install QT environment and just run this app. 我想将此应用程序发送给我的朋友,他们不应该安装QT环境并仅运行此应用程序。

dirs on my pendrive Pendrive上的目录

/ app.exe plugins (dir) -qsqlpsql.dll -sqldrivers (dir) --qsqlpsql.dll / app.exe插件(dir)-qsqlpsql.dll -sqldrivers(dir)--qsqlpsql.dll

what should i do? 我该怎么办? where did i mistake? 我在哪里弄错了?

pro file: 专业档案:

QT       += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = NZP
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui
win32{
LIBS += -L"C:/Program Files/psqlODBC/0903/bin"
}
RC_FILE += Info.rc

in my main.cpp: 在我的main.cpp中:

QApplication a(argc, argv);
   qDebug()<<QCoreApplication::applicationDirPath();
   a.addLibraryPath(QCoreApplication::applicationDirPath());
   a.addLibraryPath(QCoreApplication::applicationDirPath()+"/plugins");
   qDebug()<<a.libraryPaths();

    MainWindow w;
    w.show();

    return a.exec(); 

if i run this app under windows, where i installed QT - everythink is correct, but if i move it on pendrive or run under machine without QT framework - i become error: 如果我在安装QT的Windows下运行此应用程序-Everythink是正确的,但是如果我将其移动到pendrive上或在没有QT框架的机器下运行-我会出错:

QSqlDatabase: QPSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL QPSQL7

Failed to open database connection. 无法打开数据库连接。 Invalid driver specfied. 指定了无效的驱动程序。

i have looked in internet, but by now without sensible solution help! 我已经看过互联网,但是到目前为止,没有明智的解决方案帮助!

Ugh! 啊! i found the problem! 我发现了问题!

1. you have in your install destination this folder structure: 1.在安装目标中,此文件夹结构为:

yourap.exe
-plugins -> folder
--sqldrivers -> folder
and you have to copy from migws/bin  not QT/Tools/Creator/bin! 
---qsqlpsql.dll

in your app directory you have to copy 在您的应用程序目录中,您必须复制

libeay32.dll

with you found in: 与您一起位于:

C:\Program Files\psqlODBC\0903\bin (http://www.postgresql.org/ftp/odbc/versions/msi/   - ii used https://ftp.postgresql.org/pub/odbc/versions/msi/psqlodbc_09_03_0300.zip)

in your app (main.cpp), just add path: 在您的应用程序(main.cpp)中,只需添加路径:

QApplication a(argc, argv);
a.addLibraryPath(QCoreApplication::applicationDirPath()+"/plugins/");
a.addLibraryPath(QCoreApplication::applicationDirPath());

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

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