QSound::play(“soundpath”) call works but a QSound

2019-07-21 13:33发布

问题:

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.

标签: qt audio wav