Are you sure your path is correct? If Qt can’t find the file it gives the “error decoding source” message which is misleading.
Add files to your resource file:
- (If you haven’t already created one go to File | New | Qt | Qt Resource File).
- Click Add existing files then select sound files you want
- Right click and copy path
- Paste path to play filename. e.g. QSound::play(“:/lose.wav”);
确定音频文件的路径正确?如果QT未找到文件,它给出错误信息“error decoding source”而产生误导。
将文件添加到resource文件:
- 如果没这个文件,文件|新建|Qt|Qt资源文件
- 点击 添加已存在文件,选择要播放的文件
- 右键点击并拷贝路径
- 粘贴路径给要播放的文件名,如: QSound::play(“:/lose.wav”);
