title: Simple sound (.wav) playing application in QT (C++)
body: <p>I am new to Qt and was trying to write a simple qt class that can plan a wav file.
  After some reading and looking around I wrote the class and the code is as below. Questions follow after code</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "playsound.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, char *argv[])
  {
       QApplication a(argc, argv);
       playSound w;
       int ch = 2;
       int ready = 1;
       cout&lt;&lt;"ready"&lt;&lt;ready&lt;&lt;endl;
       // w.show();
       w.playwav(ch);
       return a.exec();   
  }
  </code></pre>
  
  <p>Source code for playsound.cpp</p>
  
  <pre><code>#include "playsound.h"
  
  playSound::playSound(QWidget *parent): QWidget(parent) {}
  
  playSound::~playSound() {}
  
  void playSound::playwav(int ch)
  {
  
      switch (ch)
      {
          case 1: {QSound::play("/home/alok/qtworkspace/sounds/abc.wav"); break;}
          case 2: {QSound::play("/home/alok/qtworkspace/sounds/xyz.wav"); break;}
          case 3: {QSound::play("/home/alok/qtworkspace/sounds/abc.wav"); break;}
          case 4: {QSound::play("/home/alok/qtworkspace/sounds/aaa.wav"); break;}
          case 5: {QSound::play("/home/alok/qtworkspace/sounds/nnn.wav"); break;}
      }
  }
  </code></pre>
  
  <p>Problems and questions:</p>
  
  <p>1) I want to close the application once the sound is played.As of now it says program running and I have to forcefully close it using the red button in the "Application Output" area in Qt creator. I tried using close() from Qwidget and quit() from QApplication but probably I am doing it wrong. How to go abt this?</p>
  
  <p>2) Can there be a simpler implementation for this functionality? You know something that does not involve event loops. I was trying to do it in old school C++ style where I call a function when I need to play a sound and be done with it but could not get it done. Suggestions most welcome on this one.</p>
  
  <p>Thanks</p>