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.
精彩评论