play a sound in application

  • Hi.
    i want to add a sound effect to my app
    that when i clicked on a push button that sound Run
    I Wrote this code but sound dose not play!
    what i must do?

     void MainWindow::on_pushButton_2_clicked()
        QSound bts("/sounds/cartoon005.wav");;

  • most likely it can't find the file. try using absolute path
    Did you deploy the multimedia plugin?

  • @VRonin
    i add the multimedia with this code

    QT       += multimedia

  • Hi,

    Widget::Widget(QWidget *parent)
    : QWidget(parent)
    glayout = new QGridLayout(this);
    pb_b1 = new QPushButton("sound");

    void Widget:: SLT_playSound(){

  • What system are you running? Widows?

  • Hi
    Yes i am using windows.

  • make sure qtaudio_windows.dll and qtmedia_audioengine.dll plugins are deployed correctly

  • The above code working as expected. So i hope qtaudio_windows.dll and qtmedia_audioengine.dll plugins are deployed correctly. Please let me know if any issue with my code.

  • @yuvaram
    thanks a lot :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.