我不確定我是否正確理解QSound.setLoop函數應該如何工作。Qt:如何用QtSound重複聲音x次
我想播放一些波形文件3次。嘗試了下面的代碼,但它只播放一次。
QSound soundObj(filePath);
soundObj.setLoops(3);
soundObj.play();
幫助:-)
編輯: 這段代碼的完整版本看起來像這樣
void Alarms::playSound(QString filePath)
{
QSound soundObj(filePath);
soundObj.setLoops(3);
soundObj.play();
}
這應該工作得很好。不久之後你能停止聲音嗎? – Bart 2011-04-11 20:47:48
你說得對:)我的QSound對象被破壞太快了。我使用動態分配,而且效果很好。 – Seba 2011-04-11 22:11:30
:)必須是這樣的。很高興它解決了。 – Bart 2011-04-12 05:50:39