Qt开发,报错:This application failed to start because no Qt platform plugin could be initialized.

       Qt开发,报错:This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

一、问题描述。

        在Qt5.14.2开发中,将执行程序所需要的库移至同一目录下后,程序无法运行。提示如下。

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""

1127, FromFilemap

This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

 二、问题分析。

        执行程序在运行时,默认先在当前目录下查找库文件。缺少Qt platform plugin下的库。

三、解决方案。

1、方法一。

        创建环境变量。此方法需安装Qt对应的版本。

变量名:QT_QPA_PLATFORM_PLUGIN_PATH

值:D:\Qt\Qt5.14.2\5.14.2\msvc2017\plugins

 2、方法二。

        拷贝plugins/platforms下的库文件至执行程序目录下,目录为执行程序下./plugins/platforms。

 

Guess you like

Origin blog.csdn.net/weixin_43782998/article/details/121029405