Qt+VS报错This application failed to start because no Qt platform plugin could be initialized.

Qt+VS报错This application failed to start because no Qt platform plugin could be initialized.

运行exe,报错:
Qt+VS报错This application failed to start because no Qt platform plugin could be initialized._第1张图片
原因:发布的exe找不到Qt依赖的环境
两种解决方案

  • 设置环境变量:
    变量名:QT_QPA_PLATFORM_PLUGIN_PATH
    变量值:D:\Qt5.12.0\install\5.12.0\msvc2017_64\plugins\platforms
    不同用户,变量名一致,变量值随文件位置变。
    最后,保存变量后,一定要重启电脑,因为新的环境变量要重启后才能被系统识别!
    亲测有效,一招解决错误:This application failed to start because not Qt platform plugin could be initialized.
  • 发布的exe路径放到具有Qt环境的路径下即可
    QT运行显示 This application failed to start because it could not find or load the Qt platform plugin

你可能感兴趣的:(Qt笔记,qt)