| ID | ... | Creation date | 17 March 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | S60 Emulator |
| Category | Qt for S60 | Subcategory | Application |
| Keywords (APIs, classes, methods, functions): QSound |
The QSound class provides access to the platform audio facilities.QSound
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 *sound=new QSound("C://Documents and Settings//Viral//My Documents//sound//Windows XP Startup.wav");
sound->setLoops(3);
QObject::connect(play,SIGNAL(clicked()),sound,SLOT(play()));
QObject::connect(stop,SIGNAL(clicked()),sound,SLOT(stop()));
#include <QtGui/QApplication>
#include "widget.h"
#include<QSound>
#include<QPushButton>
#include<QHBoxLayout>
#include<QWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QSound *sound=new QSound("C://Documents and Settings//Viral//My Documents//sound//Windows XP Startup.wav");//getting the audio file
sound->setLoops(3);//three times that specific audio file is played
QPushButton *play=new QPushButton("PLAY");//press button to play sound
QPushButton *stop=new QPushButton("STOP");//press to stop playing
QObject::connect(play,SIGNAL(clicked()),sound,SLOT(play()));
QObject::connect(stop,SIGNAL(clicked()),sound,SLOT(stop()));
lay->addWidget(play);
lay->addWidget(stop);
win->setLayout(lay);
win->showMaximized();
win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
return a.exec();
}
No related wiki articles found