PDA

View Full Version : QThread doent work for QSound



anafor2004
19th November 2008, 15:23
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




QSound sound = new QSound("a.wav");;
void myThread::run()
{
printf("thread is running\n");
forever{
printf("thread is in forever loop\n");
mutex.lock();
bool MultiSound = this->MultiSound;
int SingleSType = this->SingleSType;
int mFrequency = this->mFrequency;
bool GSoundType= this->GSoundType;
mutex.unlock();

if(!MultiSound)
{
if(sound->isAvailable())
{
sound->play();
}
}
if(abort)
return;
}
mutex.lock();
if(!restart)
condition.wait(&mutex);
mutex.unlock();
}


Do you have any suggestion?

lyuts
19th November 2008, 15:56
What if you create QSound inside run() ?

anafor2004
19th November 2008, 16:00
I tried that also but it still doesnt work