PDA

View Full Version : QThread Error



QbelcorT
23rd June 2009, 01:51
Hi,
I am using the static QSound::play in a non-qt thread. I am getting this error .
08:45:59:855 Debug: QObject: Cannot create children for a parent that is in a different thread.(Parent is QApplication(0xbebf097c), parent's thread is QThread(0x2cb388), current thread is QThread(0x1bad3f0)
08:45:59:861 Debug: QObject::startTimer: QTimer can only be used with threads started with QThread.
It is only displayed the first time I play a sound, then never shown again. Everything is working. Should I be concerned about this error? Will it cause a problem?
Thank you.

wysota
23rd June 2009, 11:22
If you're bothered about it, use QApplication::postEvent() (or sendEvent()) to post an event to the main thread and in the custom event handler play the sound. This way it'll be played in the main thread and the warning should go away.