Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Could not find or load the qt platforms plugin "windows"
Forum Updated to NodeBB v4.3 + New Features

Could not find or load the qt platforms plugin "windows"

Scheduled Pinned Locked Moved Unsolved General and Desktop
visual studioqt5.7cmakewindows 10
5 Posts 3 Posters 8.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ynirkinY Offline
    ynirkinY Offline
    ynirkin
    wrote on last edited by ynirkin
    #1

    Hi,
    I know this is a repeating issue but none of the suggested solution I found managed to solve this problem.

    I get the following error on release configuration only: "This application failed to start because it could not find or load the Qt platform plugin "windows"".

    It does work on debug configuration.
    I did set the QT_QPA_PLATFORM_PLUGIN_PATH environment variable to "Qt\5.7\msvc2015_64\plugins\platforms" directory and I also tried to create a platforms directory in my exe directory and copy the qwindows.dll there.

    I use Visual Studio 2015 Community with CMake 3.5.2 and Qt5.7.
    My CMake code:

    cmake_minimum_required(VERSION 3.1.0)
    project(qt5_test)
    
    # Find dependencies
    # ===================================================
    # Find the QtWidgets library
    find_package(Qt5Widgets)
    
    # Add executable
    # ===================================================
    #include_directories(${Qt5Widgets_INCLUDE_DIRS})
    #add_executable(qt5_test WIN32 main.cpp main_windows.cpp)
    add_executable(qt5_test WIN32 main.cpp)
    
    # Use the Widgets module from Qt 5.
    target_link_libraries(qt5_test Qt5::Widgets)
    

    My application code:

    #include <qapplication.h>
    #include <qpushbutton.h>
    
    int main(int argc, char **argv)
    {
        QApplication a(argc, argv);
    
        QPushButton hello("Hello world!", 0);
        hello.resize(100, 30);
        hello.show();
        return a.exec();
    }
    

    Please help.

    Thanks in advance,
    Yuval

    raven-worxR 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Did you try with the windows deployment tool? http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      ynirkinY 1 Reply Last reply
      0
      • VRoninV VRonin

        Did you try with the windows deployment tool? http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool

        ynirkinY Offline
        ynirkinY Offline
        ynirkin
        wrote on last edited by
        #3

        @VRonin I tried now and it does work! Thank you.
        But is there a way to make this work without copying the dlls around?

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          you can use QCoreApplication::addLibraryPath to decide the search locations for your plugins

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • ynirkinY ynirkin

            Hi,
            I know this is a repeating issue but none of the suggested solution I found managed to solve this problem.

            I get the following error on release configuration only: "This application failed to start because it could not find or load the Qt platform plugin "windows"".

            It does work on debug configuration.
            I did set the QT_QPA_PLATFORM_PLUGIN_PATH environment variable to "Qt\5.7\msvc2015_64\plugins\platforms" directory and I also tried to create a platforms directory in my exe directory and copy the qwindows.dll there.

            I use Visual Studio 2015 Community with CMake 3.5.2 and Qt5.7.
            My CMake code:

            cmake_minimum_required(VERSION 3.1.0)
            project(qt5_test)
            
            # Find dependencies
            # ===================================================
            # Find the QtWidgets library
            find_package(Qt5Widgets)
            
            # Add executable
            # ===================================================
            #include_directories(${Qt5Widgets_INCLUDE_DIRS})
            #add_executable(qt5_test WIN32 main.cpp main_windows.cpp)
            add_executable(qt5_test WIN32 main.cpp)
            
            # Use the Widgets module from Qt 5.
            target_link_libraries(qt5_test Qt5::Widgets)
            

            My application code:

            #include <qapplication.h>
            #include <qpushbutton.h>
            
            int main(int argc, char **argv)
            {
                QApplication a(argc, argv);
            
                QPushButton hello("Hello world!", 0);
                hello.resize(100, 30);
                hello.show();
                return a.exec();
            }
            

            Please help.

            Thanks in advance,
            Yuval

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @ynirkin said:

            It does work on debug configuration.
            I did set the QT_QPA_PLATFORM_PLUGIN_PATH environment variable to "Qt\5.7\msvc2015_64\plugins\platforms" directory and I also tried to create a platforms directory in my exe directory and copy the qwindows.dll there.

            You shouldn't set it to the "platforms" folder, but to the (parent) "plugins" folder instead.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved