Important: Please read the Qt Code of Conduct -

Proper way playing oga files as sound effects

  • I am developing a GUI application under Ubuntu Linux with Qt5.
    I want to use sounds from "/usr/share/sounds/freedesktop/" as sound effects, which contains .oga files. However, the QSoundEffect class seems to understand only .wav files. qDebug() << QSoundEffect::supportedMimeTypes(); outputs

    ("audio/x-wav", "audio/vnd.wave")

    and the application prints QSoundEffect(pulseaudio): Error decoding source at initialization.
    Is there a way to play these files?

    I use the QSoundEffect as in the code snippet below. Is this the proper way to use the class?
    Is using QMediaPlayer instead of QSoundEffect an overkill?

    class MyClass: public QDialog {
        MyClass(QObject * parent = nullptr): QDialog(parent) {
        QSoundEffect * ok = new QSoundEffect(this);
        sound_effects_["ok"] = ok;
       /*Initialize other effects*/
        connect(this, &MyClass::PlaySound, this, &MyClass::Play);
    void AFunctionFromADiffernetThread(){
         // Do other things
            emit PlaySound("ok");
        void PlaySound(const QString & name);
    private slots:
      void Play(const QString & name){
        QMap<QString, QSoundEffect *> sound_effects_;

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The details of QSoundEffect explain that only uncompressed formats are supported, typically wav files.

Log in to reply