I've got an object that I want to live in another thread, so in a class in my main thread I've got:
// pseudo-code, may not compile QThread* thread = new QThread(this); myObject* foo = new myObject(); foo ->moveToThread(thread); thread->start(); But when I go to connect the signals/slots between objects in the main thread and the "foo" object, should I do that before I move that object to a different thread, or after, or does it not matter? So should it be either: QThread* thread = new QThread(this); myObject* foo = new myObject(); // make calls to connect() before calling moveToThread() connect(this, SIGNAL(...),foo, SLOT(...)); // repeat as necessary for all my signal/slot connections foo->moveToThread(thread); thread->start(); Or: QThread* thread = new QThread(this); myObject* foo = new myObject(); foo->moveToThread(thread); thread->start(); // make calls to connect() after calling moveToThread() connect(this, SIGNAL(...),foo, SLOT(...));// repeat as necessary for all my signal/slot connections Or even delaying the thread->start() call until after everything else: QThread* thread = new QThread(this); myObject* foo = new myObject(); foo->moveToThread(thread); // make calls to connect() after calling moveToThread() then call thread->start() connect(this, SIGNAL(...),foo, SLOT(...));// repeat as necessary for all my signal/slot connections thread->start(); I can't find any authoritative documentation that says to do it one way or the other, so either it doesn't exist or more likely, I'm not googling well. I can find lots of docs on the merits of inheriting from QThread vs. using the moveToThread(), but the ones I've found don't address this question in detail. Sean
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest