How to solve the “no Qt platform plugin could be initialized” problem?

笑着哭i 提交于 2020-08-11 18:45:00

问题


I'm trying to run a simple template in release mode on Visual Studio with the Qt extension. So far I've always been running projects in debug mode (never had trouble). Recently, I started with a browser application using webengine its widgets, but it's very slow on debug mode, so. I wanted to make sure it's possible to run with higher performance (on release mode), before continuing.

I was surprised, because the application throws 4 error message pop-ups after each other after trying to run it:

  • The procedure entry point ?endl@QTextStreamFunctions@@YAAEAVQTextStream@@AEAV2@@Z could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.

  • The procedure entry point ?argToQString@QQtPrivate...QString...QStringView... could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.

  • Two more similar ones for QDebug and QRhiDepthStencilClearValue.

So instead, I tried to compile a simple project (the direct QtWidgetsApplication template) and it gave me this:

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

I've been looking for a solution for quite some time now, but I didn't find a clear answer.

My directory: C:\Qt\5.14.1\msvc2017_64

My template code:

#include "QtWidgetsApplication2.h"
#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QtWidgetsApplication2 w;
    w.show();
    return a.exec();
}
#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_QtWidgetsApplication2.h"

class QtWidgetsApplication2 : public QMainWindow
{
    Q_OBJECT

public:
    QtWidgetsApplication2(QWidget *parent = Q_NULLPTR);

private:
    Ui::QtWidgetsApplication2Class ui;
};
#include "QtWidgetsApplication2.h"

QtWidgetsApplication2::QtWidgetsApplication2(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
}

I have no clue of how to fix this problem. Could you please help me out? Thanks in advance!


回答1:


See if this helps.

Are you trying to start the program by double clicking the .exe ? I tried to reproduce it:

  • build a simple project in release mode
  • run windeployqt ... and delete the generated folder ./platforms
  • double click on .exe to run it.

and prompts the error message you got.



来源:https://stackoverflow.com/questions/62559840/how-to-solve-the-no-qt-platform-plugin-could-be-initialized-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!