3

I am trying to play a sound with QSound module.

It try with this code and works:

QSound::play(":/sounds/sources/BeepSound.wav");

But I want this and doesn't work:

I create a dynamic instance of QSound and played:

sounds = new QSound(":/sounds/sources/BeepSound.wav");
sounds->setLoops(3);
sounds->play();

Any tips?

Update

I don't want to use others modules like QMediaPlayer, QAudioOutput because I want something really simple, just play a sound.

Robert
  • 10,403
  • 14
  • 67
  • 117
  • @vizhanyolajos Please refrain from adding spaces inside function-call parentheses, it is not a common style and it makes edits too noisy for those of us in the review queue. – o11c Jun 13 '15 at 00:26
  • What OS and Qt Version are you running? QSound is a little weak across platforms and possibly deprecated from what I remember. Have you tried QSoundEffect? – davepmiller Jun 13 '15 at 00:43
  • OS: Windows 8, and Qt 5.4.1 – Robert Jun 13 '15 at 02:12
  • I'm having this issue too. `QSound` will work in my `main()` function but not in any of my classes. It's very odd. – developer01 Sep 03 '21 at 19:47

0 Answers0