QT平台dll应该去哪里? [英] Where are QT platform dlls supposed to go?

查看:174
本文介绍了QT平台dll应该去哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个使用QTWebKit的功能的DLL,然后我通过JNA在java端访问。在我的机器上(显然安装了QT)它工作正常。当我移动到另一台机器来测试没有安装qt的时候,我得到:

I have created a DLL that uses some functionality from QTWebKit, that I then access through JNA on the java side. On my machine (which QT is installed on obviously) it works fine. When I move it to another machine to to test it that does not have qt installed I get:


无法加载平台插件windows 。可用的平台有:

Failed to load platform plugin "windows". Available platforms are:

我的google fu指出,我还需要包括平台DLL,即 qwindows.dll qminimal.dll 。根据在Windows上部署应用程序的QT5文档看起来像在部署可执行文件时,它将在保存目录中作为可执行文件的名为 platform 的文件夹。

My google fu as pointed me to the fact that I need to also include platform DLLs, namely qwindows.dll and qminimal.dll. According to the QT5 documentation in Deploying an Application on Windows it sounds like when deploying an executable it would be in a folder called platforms in the save directory as the executable.


与用户插件相反,Qt插件必须放入匹配插件类型的
子目录中。因为我们要部署
的Windows平台插件,它必须被放入一个平台
子目录。

In contrast to user plugins, Qt plugins have to be put into subdirectories matching the plugin type. As we want to deploy the windows platform plugin it has to be put into a "platforms" subdirectory.



<这导致我的困境。我有一个DLL,而不是可执行文件。所以我不知道把平台文件夹放在哪里。我试图将它放在我执行我的测试应用程序的同一个目录中,但是没有起作用。

That leads me to my dilemma. I have a dll, not an executable. So I have no clue where to put the platform folder. I have tried to place it in the same directory I am executing my test application, but that did not work.

那么在哪里可以放置平台目录以使QT能够找到?

编辑:
由于我没有太多的反馈意见,也许有更好的方法来处理这个问题。

Since I have not had much feedback, maybe there is a better way to word/approach this question.

如何告诉QT哪里可以找到平台DLL?

似乎有一种办法可以实现这一点。当我在我的机器上运行它,它最终在 C:\Qt2\Qt5.0.2\5.0.2\msvc2012_64\plugins\platforms 。因此,似乎有一个

It seems like there has to be a way to accomplish this. When I run it on my machine, it ends up looking in C:\Qt2\Qt5.0.2\5.0.2\msvc2012_64\plugins\platforms. So it seems there m

推荐答案

我已经找到了两个可能的解决方案,您需要创建一个(与正常创建具有一个exe的Qt应用程序基本不同)。

I have found two possible solutions for the scenario that you need to create a QApplication inside a DLL or library (basically different from the normal create Qt application that has an exe).


  1. 最简单的解决方案是将系统环境变量 QT_QPA_PLATFORM 设置为您希望平台位于的文件夹。我不喜欢这个解决方案,担心它可能会干扰安装在终端系统上的其他应用程序。

  1. The easiest solution is to set the system environment variable QT_QPA_PLATFORM to the folder that you expect the platforms to be located at. I did not like this solution do to the fear that it could interfere with other applications installed on the end system.

下一个解决方案是利用正常的QT应用程序将使用的命令行参数。在正常的Qt应用程序中 QApplication 将在您的主题中创建,类似于:

The next solution is to take advantage of the command line parameters that a normal QT application would use. In a normal Qt application QApplication would be created in your main similar to:

int main(int argc, char *argv[]) {
   QApplication app(argc, argv);

   //other code

   return app.exec();
}

我们必须创建 argv argc 在这一点上,所以使用这个我们的优势。

Well we have to create argv and argc anyway at this point so use that to our advantage.

char *argv[] = {"YourAppName","-platformpluginpath", "C:/your/path/to/dll/folder", NULL};
int argc = sizeof(argv) / sizeof(char*) - 1;

QApplication app(argc, argv);


注意:即使现在googling为 -platformpluginpath 我找不到任何信息。或有关其他命令行参数可用于QT的信息。我通过挖掘QT源代码找到一个解决方案。所以如果任何人碰巧有一个资源的链接与该信息,将是方便的留下评论。

NOTE: Even now googling for -platformpluginpath I could not find any information for it. Or information on what other command line parameters may be available to use with QT. I found it by digging into the QT source code while looking for a solution. So if anyone happens to have a link to a resource with that information it would be handy to leave a comment with it.

这篇关于QT平台dll应该去哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆