开发者

Qt: How to repeat sound x times with QtSound

开发者 https://www.devze.com 2023-02-23 13:17 出处:网络
I\'m not sure I understand correctly how QSound.setLoop function should work. I want to play some wave file 3 times. Tried the following code but it only plays it once.

I'm not sure I understand correctly how QSound.setLoop function should work.

I want to play some wave file 3 times. Tried the following code but it only plays it once.

QSound soundObj(filePath);
soundObj开发者_运维问答.setLoops(3);
soundObj.play();

Help :-)

Edit: The full version of this code looks like this

void Alarms::playSound(QString filePath)
{
    QSound soundObj(filePath);
    soundObj.setLoops(3);
    soundObj.play();
}


soundObj object is destroyed to quickly.
Has to be allocated dynamically.

0

精彩评论

暂无评论...
验证码 换一张
取 消