开发者

Qt: How to repeat sound x times with QtSound

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜