Could not find or load the Qt platform plugin "windows"

  • I'm having a heck of a time with the classic "Could not find or load the Qt platform plugin 'windows'" message. I have tried everything I can find on this forum or StackOverflow to solve it. I'm experienced using Qt and have deployed my code, which is an addon to Internet Explorer, successfully before, but that was with Qt4. Now I can't get it to run with Qt5.51. The same code loads and runs on my development PC, and under Chrome and Firefox. But with Internet Explorer, no matter what I do, I see the message about not being able to find the Windows plugin.
    My current attempt is based on using windeployqt to create a directory structure, which I then copy to the target PC. The files in my deployment are:

    The folders in the deployment include the files windeployqt puts there -- in particular platforms\ contains qwindows.dll.
    I've verified that the deployment PC has the VS 2010 and 2013 redistributables installed. (I'm compiling with VS 2010). I've verified the same behavior on Windows XP and IE 8, as well as Windows 7 and IE 11.
    I also tried copying all the DLLs from Qt into the deployment folder, all the plugins, adding the current folder to the search path using addLibraryPath, including a qt.conf file giving the path to the platforms folder, etc -- everything I could find on the forums. Nothing made a difference. I've also used Dependency Walker to search for missing DLLs.
    Any ideas?

  • Hi, I'm guessing because you're deploying a .dll and not an .exe the loading of plugins is more troublesome. Because normally Qt tries to load the plugins from subdirectories in the current directory, which usually is where the .exe file is (which means Program Files (x86)... Internet Explorer's .exe and not your deployment dir). Same for the qt.conf, Qt expects it in the current directory, so try putting a qt.conf where Internet Explorer's exe is.

    Calling addLibraryPath() should however have fixed the problem for you, but do you call it before QApplication a(argc, argv); in your main.cpp? If not it has no effect :-(

    P.S. To help debug this, you could set an environment variable:
    and then use DebugView to see the output.

  • Thanks. I finally figured out the problem. The platforms folder wasn't being found because it wasn't included in the search path.
    I had code that would include the install directory in the search path, using addLibraryPath, but the code was #ifdef'd with the Q_WS_WIN macro. This seems to be Q_OS_WIN in Qt5. So the code wasn't executed.
    In Chrome, apparently, the current directory is set to the directory of the .dll prior to execution. So the code worked in Chrome. But this doesn't seem to happen in Internet Explorer.
    At one point I'd run across a potential fix for this problem -- set the environment variable QT_QPA_PLATFORM_PLUGIN_PATH to the platforms folder -- but I think the variable name was misspelled in the forum. So when I tried to set it, it had no effect.
    BTW, I eventually found the problem by downloading the Qt 5.5.1 source, and using the .pdb files included with my distribution to see what was going on. This was troublesome, but invaluable. So thanks to the Qt developers for making that possible.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.