Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This application failed to start because it could not find or load the Qt platform plugin "windows" error message

Tags:

c++

qt

platform

qt5

I have created an application by using Qt v5.3.1 with MinGW v4.8.2 on windows 7 32bit.
I have the following error when open my application:

I've inclusion all important files to run my application by using windeployqt.exe tool.

Also the platforms folder contains:

Also I've inclusion all important files to run my application manually without use windeployqt.exe tool, and the problem still exists.

I don't know how to solve this problem .


Edit

The the result of using Dependency Walker tool.

I'm still don't know how to get these dll files question mark.

like image 425
Lion King Avatar asked Oct 20 '22 02:10

Lion King


1 Answers

Firstly, thank everyone for contributing to the understanding of the problem and how to solve it.

Now, to solve this problem you must read this article Accurately, in order to understand first what is the problem, and then how to solve it. [Deploying a real Qt app – understanding more of Qt]

The conclusion In short :
the reason of the problem is the path of the plugins that you used in your project.
The default path to plugins that you used in your project is qt path folder, but when qt development environment not be installed on your machine, your application will not run, because the default path to plugins directed to qt path folder, and this is the problem.
We need to direct/change the plugins path to your application folder.

There are several ways to direct/change the path. I will mention the way in which I have already tried and succeeded in solving the problem

There is a static method named addLibraryPath(const QString & path), this method We will use it to direct/change the plugins path.

Example:

int main(int argc, char *argv[])
{
    QApplication::addLibraryPath("pluginsFolder");
    QApplication a(argc, argv);
    Widget w;
    w.show();


    return a.exec();
}

pluginsFolder is the folder that contain all plugins that you used in your project.

You can also change

QApplication::addLibraryPath("pluginsFolder");

To

QApplication::addLibraryPath(".");

This means that the plugins in the main application folder not in subdirectory named plugins.
And don't forget to use windeployqt.exe tool to deploy your project.

And finally, I hope that this the short explanation will be useful for those after me, who will face the same problem.

like image 85
Lion King Avatar answered Oct 22 '22 17:10

Lion King