I want to play a wav file if a singal is emitted. For testing i created a pushButton and filled its slot with
QSoundEffect alarm;
alarm.setSource(QUrl::fromLocalFile("001.wav"));
alarm.setLoopCount(QSoundEffect::Infinite);
alarm.setVolume(1.0f);
alarm.play();
But there is no sound if i click on the pushButton. After searching i found people having the same problem with Qt5 but no solution.
Whats the best and simplest solution with Qt5 to just play an uncompressed sound file (wav) and change its volume?
EDIT: I just found out that it works if i add e.g. a QMessageBox (while this message box is open):
QSoundEffect alarm;
alarm.setSource(QUrl::fromLocalFile("001.wav"));
alarm.setLoopCount(2);
alarm.setVolume(0.5f);
alarm.play();
QMessageBox::information(this, "test", "it works");
Has anybody an explanation for this behaviour?