In the header define the following

Qt Code:
  1. private:
  2. QPointer <QMediaPlayer> mp3backgroundplayer;
  3.  
  4.  
  5. signals:
  6.  
  7. void playmp3background();
  8. void stopmp3background();
To copy to clipboard, switch view to plain text mode 


in the code use this to load it from the resource file

Qt Code:
  1. QPointer <QMediaPlayer> mp3backgroundplayer = new QMediaPlayer (this);
  2. // ...
  3. mp3backgroundplayer->setMedia(QUrl("qrc:/spacegame/images/gamemedia/spacegamebackground.mp3"));
  4. mp3backgroundplayer->setVolume(30);
  5. mp3backgroundplayer->l
  6.  
  7. mp3backgroundplayer->play();
  8. connect(this,SIGNAL(playmp3background()),mp3backgroundplayer.data(),SLOT(play()));
  9. connect(this, SIGNAL(stopmp3background()), mp3backgroundplayer.data(), SLOT(stop()));
To copy to clipboard, switch view to plain text mode 


to stop use this

Qt Code:
  1. this.emit(stopmp3background());
To copy to clipboard, switch view to plain text mode 


good luck