具体播放系统声音使用Qt [英] Playing specific system sound with Qt

查看:479
本文介绍了具体播放系统声音使用Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序发出一个标准的通知声音,这就是所谓的默认叫声在Windows上的人。我没有看到参考系统的方式与QSound的声音。没有声音QSound的情况下转让应经常玩这个声音,但它固定在Qt的5.任何办法做到这一点?

I want my application to emit a standard notification sound, the one that's called "Default Beep" on Windows. I don't see a way of referencing system sounds with QSound. QSound instance with no sound assigned used to play this sound, but it's fixed in Qt 5. Any way to do it?

这是确定的,如果解决方案仅适用于Windows(但我想它编译于任何支持的OS,并且不希望使用 #IFDEF 和Win API)。

It's OK if the solution only works on Windows (but I want it to compile on any supported OS and don't want to use #ifdef and Win API).

推荐答案

使用声子(的 http://qt-project.org/doc/qt-4.8/phonon-overview.html ),一个Qt库,它能够播放声音/视频,...

Use Phonon ( http://qt-project.org/doc/qt-4.8/phonon-overview.html ), a Qt library, which is able to play sound / video, ...

有关的文件的路径,你应该使用环境变量的WINDOWS目录下,然后硬code中的声音文件的路径的末尾

For the path of the file, you should use environment variable for the WINDOWS directory, and then hard code the end of the path of the sound file

但是:我想,它可能的不可以是一个好主意,因为系统的声音可以个性化...要得到你需要的个性化声音的路径读取windows的注册表...

But : I am thinking that it may not a good idea, since the system sound can be personalized... To get the PATH of the personalized sound you need to read the windows registry...

编辑::您可以使用 QSettings 类能够读取Windows注册表
例如是这样的:

Edit : You could use the QSettings class to be able to read the Windows registry For example something like :

QSettings settings("HKEY_CURRENT_USER\\AppEvents\\Schemes\Apps\\.Defaults\\..TODO..", QSettings::NativeFormat);

这篇关于具体播放系统声音使用Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆