Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Hi, I would like to add a sound when i push a button, i have this code but it doesn't actually work, the error while compiling: QSoundEffect(qaudio): Error decoding source, How do i fix this please?
med12 last edited by aha_1980
QSoundEffect effect; effect.setSource(QUrl::fromLocalFile("1.mp3")); effect.setLoopCount(QSoundEffect::Infinite); effect.setVolume(50); effect.play();
Kent-Dorfman last edited by
I think it's telling you that you cannot (and I'll add should-not) attempt to use mp3 for the purpose you describe. Try loading a raw PCM file like WAV format instead.
med12 last edited by
i tried to use a wav file but it generates the same error(QSoundEffect(qaudio): Error decoding source)
Bonnie last edited by
Where do you put this wav file? Try to use the full path.
Hi and welcome to devnet,
You are using a relative path so your application will not find the file as it is not located in the same folder.
On an unrelated not, please give your thread a meaningful title and put the actual text of your enquiry as the body of the post along with your code.