Results 1 to 3 of 3

Thread: QThread doent work for QSound

  1. #1
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default QThread doent work for QSound

    Hi all
    I want to play some QSound objects via QThread but i couldnt do it.It make a failure notice.

    It says ;

    QObject: Cannot create children for a parent that is in a different thread.
    (Parent is QApplication(0xbefffd10), parent's thread is QThread(0x8d93a0), current thread is myThread(0xbAlignment trap: deneme (957) PC=01
    efffcd0)
    Bus error


    Qt Code:
    1. QSound sound = new QSound("a.wav");;
    2. void myThread::run()
    3. {
    4. printf("thread is running\n");
    5. forever{
    6. printf("thread is in forever loop\n");
    7. mutex.lock();
    8. bool MultiSound = this->MultiSound;
    9. int SingleSType = this->SingleSType;
    10. int mFrequency = this->mFrequency;
    11. bool GSoundType= this->GSoundType;
    12. mutex.unlock();
    13.  
    14. if(!MultiSound)
    15. {
    16. if(sound->isAvailable())
    17. {
    18. sound->play();
    19. }
    20. }
    21. if(abort)
    22. return;
    23. }
    24. mutex.lock();
    25. if(!restart)
    26. condition.wait(&mutex);
    27. mutex.unlock();
    28. }
    To copy to clipboard, switch view to plain text mode 


    Do you have any suggestion?

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QThread doent work for QSound

    What if you create QSound inside run() ?
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: QThread doent work for QSound

    I tried that also but it still doesnt work

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.