Hi

I'm having some problems with the QObject::setParent() function across threads. I'm seeing this behavior on windows only. On mac it works fine. Qt 4.6.2 in used on both platforms.
Here is the code:

Qt Code:
  1. MyObject *object = new MyObject();
  2. if (parent) {
  3. if (parent->thread() != object->thread()) {
  4. object->moveToThread(parent->thread());
  5. }
  6. Q_ASSERT(parent->thread() == object->thread());
  7. object->setParent(parent);
  8. }
To copy to clipboard, switch view to plain text mode 

The error message is as follows:

Cannot send events to objects owned by a different thread. Current thread 588d088. Receiver 'MyObject' (of type 'MyObject') was created in thread a4f690

What could be wrong?