QSound error in thread



  • Hello,

    I am trying to play a sound in a non-qt thread:

    QSound::play(":/button20.wav");
    

    I receive this error:
    QObject: Cannot create children for a parent that is in a different thread.

    Any ideas ?

    Thanks,

    Alex



  • Can you create an instance and play that?

    #include <QSound>
    ...
    QSound button20Sound(":/button20.wav");
    button20Sound.play();
    


  • Thank you for your answer.
    With your method, the error is not there anymore.

    However, I don't hear the sound. I hear it when I play the file outside the thread (in the main).


Log in to reply
 

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