Qt的:如何播放声音不用其他阻塞主线程? [英] Qt: How to play sound witout blocking main thread?
问题描述
我不知道是否有Qt中的一个简单的方法来播放声音,而不会阻塞主线程?
我知道我normaly应该开始一个单独的线程来做到这一点。但是,也许有捷径? :)
感谢您的帮助。
的http:// doc.qt.nokia.com/latest/qsound.html
Qt提供的GUI应用程序中最常用所需的音频操作:异步播放声音文件。这是使用静态的戏最容易实现的()函数:
块引用>QSound的发挥::(mysounds / bells.wav);
看起来这是一个异步操作,所以它不应该阻止你的主线程。
I'm wondering is there a simple way in Qt to play sound without blocking the main thread ?
I know that normaly I should start a seperate thread to do this. But maybe there is a shortcut ? :)
Thanks for help.
解决方案http://doc.qt.nokia.com/latest/qsound.html
Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static play() function:
QSound::play("mysounds/bells.wav");
It seems like this is an asynchronous operation, so it shouldn't block your main thread.
这篇关于Qt的:如何播放声音不用其他阻塞主线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!