Error: could not find or load the Qt platform plugin “windows”
-
Thanks SGaist,
Here is a snapshot of my deployment dir:
!http://i.imgur.com/rjVD5Gu.png(deployment dir)! -
Shouldn't the plugin folders be located in a plugins directory? Have you tried running windeployqt?
-
Thanks Chris,
When I changed the QTDIR and PATH environment variables I was expecting to get the same error messages on machine, but I am not, that's what makes me think that somehow these paths are hardcoded in my Qt dll files.
And I do have to change the QTDIR very often to switch from Qt 4.7.1 and Qt 5.3.2. (not as much now that everything is installed).
-
I copied the entire directory:
c:\Qt\5.3.2\vs2013_64bits\qtbase\plugins
To my user's machine c: drive, and now I can execute my application in that machine.
This tells me that somehow the path c:\Qt\5.3.2\vs2013_64bits is coded in my application or the Qt dll files.
Is there any way to tell Qt where to look for these plugins?
Thank you again! -
Hi, I had same problem as you, and decided to learn more about Qt and its plugins. Turns out there are in total 7 (!) different ways you can tell Qt where to look for the plugins, I've written about it "here":http://www.tripleboot.org/?p=536#PluginDLLs
-
Thank you very much hskoglund!
Your guide seems very complete... I'll study it carefully.
I also found this:
https://qt-project.org/doc/qt-5-snapshot/deployment-plugins.htmlAnd when I look to the QLibraryInfo::PluginsPath in the debugger it is:
C:/Qt/5.3.2/vs2013_64bits/qtbase/plugins
Which apparently is set when the library is built or using qt.conf.
Thank you again!
-
According to this guide:
https://qt-project.org/doc/qt-5-snapshot/deployment-plugins.html
You can set the plugin path using QCoreApplication::addLibraryPath.
I tried to assemble the plugins path using QCoreApplication::applicationDirPath(), but this method requires that an instance of QApplication has been initialized, which fails because of no plugins!
The only way I found to set the path was using argv[ 0 ] and boost:
@
boost::filesystem::path exe_path = boost::filesystem::system_complete( boost::filesystem::path( argv[0] ) );
boost::filesystem::path dir_path = exe_path.parent_path();QString plugin_path( dir_path.string().c_str() );
plugin_path = plugin_path + "/qt_plugins";
plugin_path.replace( "\", "/" );QCoreApplication::addLibraryPath( plugin_path );
@This works but the argv[ 0 ] makes it iffy.
-
Hi, if you just want to tell Qt to look for the plugins in a subdirectory below your .exe file, you can use a relative path syntax (i.e. no C: or slashes):
!http://tripleboot.org/Qt/AddLibrary.png(addLibraryPath example)! -
Hmm just tried it, maybe my testapp is too simple. Anyways, there are other alternatives to tell Qt about that path, you could try creating a qt.conf file and place it together with your .exe file, and stuff it with these 2 lines:
@
[Paths]
Plugins=qt_plugins
@