The user can play a sound live with a mouse click or the press of a keyboard's button. But when they record an awesome beat, the application must be able to play it again with the PlaybackWorker class. Let's see how MainWindow uses this worker. The following is the MainWindow.h related to the PlaybackWorker class:
class MainWindow : public QMainWindow { ... private slots: void playSoundEffect(int soundId); void clearPlayback(); void stopPlayback(); ... private: void startPlayback(); ... private: PlaybackWorker* mPlaybackWorker; QThread* mPlaybackThread; ... };
As you can see, MainWindow has the PlaybackWorker and QThread member variables. Let's look at the implementation of startPlayback():
void MainWindow::startPlayback() { clearPlayback(); mPlaybackThread = new...