This application failed to start because it cloud not find or load the Qt platform plugin “windows”

in “”.

Reinstalling the application may fix this problem.

 

解决办法如下:

使用 Qt 的工具生成环境

官方文档原文链接:http://doc.qt.io/qt-5/windows-deployment.html

参考链接:http://stackoverflow.com/questions/38359850/qt-5-7-0-could-not-find-or-load-the-qt-platform-plugin-windows

这里的采纳答案即是正解

原文如下:

WHY THE PROBLEM OCCURRED

Honestly, I don’t know. But it very much seems like “Alexander Saprykin” answer is correct. During the process of testing, i had to update my Qt so it could fairly well be only a version mismatch.

Also, the fact that when I redid my build using only Qt 5.7.0 it worked, implies that it was indeed only a mismatch case.

HOW I FIXED IT

As told by “Sebastian Lange” in the comments, using windeplyqt.exe did the job. I just deleted everything but the .exe in my build folder, opened Qt5.7 command line, chaged directory to the same as my .exe and ran the command windeployqt . or windeployqt [name_of_exe].exe

 

 

Qt原文翻译如下: 来自Google翻译

Windows部署工具

Windows部署工具旨在自动化创建可部署文件夹的过程,该文件夹包含从该文件夹运行应用程序所需的Qt相关依赖项(库,QML导入,插件和转换)。它为Windows运行系统或Windows桌面应用程序的安装树创建一个沙盒,可以轻松地捆绑到安装包中。

该工具可以在QTDIR / bin / windeployqt中找到。它需要一个.exe文件或包含.exe文件作为参数的目录,并扫描可执行文件以获取依赖关系。如果使用–qmldir参数传递目录,windeployqt将使用qmlimportscanner工具扫描目录中QML导入依赖关系的QML文件。然后将标识的依赖项复制到可执行文件的目录中。 Qt5Core.dll中的硬编码本地路径进一步被替换为相对的路径。

对于Windows桌面应用程序,编译器所需的运行时文件也会默认复制到可部署文件夹(除非指定了–no-compiler-runtime选项)。在使用Microsoft Visual C ++发布版本的情况下,这些包含Visual C ++可再分发软件包,用于由目标机器上的应用程序的安装程序进行递归安装。否则,将使用编译器运行时的共享库。

该应用程序可能需要额外的第三方库(例如数据库库),这些库不会被windeployqt考虑在内。

 

大致是这样。

将 windeployqt.exe 与 你的 Qt文件放在同一个目录,只要这两个文件。

要用Qt安装的这个命令工具才有用。

然后运行命令:这里name_of_exe你得知道是你的Qt生成的exe文件的名字

windeployqt.exe    [name_of_exe].exe

然后就生成一大堆文件,文件夹。

最后把你的其他非Qt的依赖库加进来,完毕~

 

【Qt】关于环境问题 – 没有Windows的组件?
Tagged on:     
0 0 投票数
Article Rating
订阅评论
提醒

0 评论
内联反馈
查看所有评论