[Qt-interest] How to make an alert sound?
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Sat Aug 22 01:55:21 CEST 2009
The issue is you have to convert the windows "Event" name into the wav
file...
There is no easy Win32 call for this either... It takes a couple of
registry calls.
First, you need to get the name of the app, then the event for the app.
Then you get the current wav file (since the sounds are themed) and you
play it...
Here is some code, that will load up a QTreeWidget with the first column
being the application event, the second being application tag name, the
third being the filename.
Note, the filename quite often contains Windows environmental variables
(%SYSTEMROOT%) so you will need to expand them in a function called
expandEnv.
Then you can use QSound::play( item->tag( 2 ) )
Scott
void CMainForm::LoadSounds()
{
QSettings settings(
"HKEY_CURRENT_USER\\AppEvents\\Schemes\\Apps", QSettings::NativeFormat
);
QStringList sections = settings.childGroups();
for( int ii = 0; ii < sections.count(); ++ii )
{
settings.beginGroup( sections[ ii ] );
QString sectionName = settings.value( "." ).toString();
QTreeWidgetItem * item = new QTreeWidgetItem(
QStringList() << sectionName );
fImpl->sounds->addTopLevelItem( item );
QStringList sounds = settings.childGroups();
QSettings soundSettings(
"HKEY_CURRENT_USER\\AppEvents\\EventLabels", QSettings::NativeFormat );
for( int jj = 0; jj < sounds.count(); ++jj )
{
settings.beginGroup( sounds[ jj ]+"/.Current" );
QString fileName = expandEnv( settings.value(
"." ).toString() );
settings.endGroup();
soundSettings.beginGroup( sounds[ jj ] );
QString text = soundSettings.value( "."
).toString();
QTreeWidgetItem * child = new QTreeWidgetItem(
QStringList() << text << sounds[ jj ] << fileName );
item->addChild( child );
soundSettings.endGroup();
}
settings.endGroup();
}
}
-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of rajasekharan
Sent: Friday, August 21, 2009 3:53 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to make an alert sound?
Alex,
I understand playing a sound using QSound. I would like to play the
sounds that are configured to be played for specific events like an
exclamation, critical error, disallowed, new mail and so on. You can
find these settings under Control Panel > Sound > Sounds Tab in Windows
Vista (similar in previous versions). I am not looking for a way to play
a sound file directly but play the sound that has been configured to
play in windows (or linux if applicable). Other than fetching the sound
file set to be played for a particular event manually and playing that
sound, are there any easier ways.
Raj Sekharan
Malyushytsky, Alex wrote:
> Have you seen QSound?
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of rajasekharan
> Sent: Friday, August 21, 2009 12:31 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] How to make an alert sound?
>
> Hi all,
>
> Windows has a set of sounds configured to be played for particular
> events such as New mail received. Some non-microsoft
> applications are able to trigger it also, how can these alert sounds
be
> triggered using a Qt Application?
>
> Thanks in advance,
>
> Raj Sekharan
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
------------------------------------------------------------------------
---------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended
recipient and may contain confidential or privileged information. If you
are not the intended recipient, any disclosure, copying, use, or
distribution of the information included in this message and any
attachments is prohibited. If you have received this communication in
error, please notify us by reply e-mail and immediately and permanently
delete this message and any attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list