Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSound doesn't work outside of Qt Creator on Windows



  • I'm trying to use QSound in my Qt program. I'm trying to play a sound which is in the Qt resources. I use the following code:

    QSound::play(":/exemple.wav");
    

    When I run my program from Qt Creator, everything works well. But when I run my program on Windows from Windows explorer, it doesn't make any sound. When I run my program on Mac or Linux, even outside of Qt Creator, it works.

    I tried literally copying the content of all the subfolders of C:\Qt\5.10.1\msvc2015 into the executable's folder in case some DLLs or other files were missing, but it didn't help (I know that a lot of those files like the includes aren't necessary for the executable, but I still tried).

    I also tried to use files on the hard drive (using the absolute path in the program) instead of qrc resources, but it still didn't work.

    How to get QSound to work outside of Qt Creator?


  • Lifetime Qt Champion

    Hi
    Make sure you make a proper deployment folder
    You can use the tool
    http://doc.qt.io/qt-5/windows-deployment.html

    also look here
    http://www.tripleboot.org/?p=138

    the subfolders of C:\Qt\5.10.1\msvc2015 might NOT reflect how the DLLS should be located.


Log in to reply