How to move an object back to mainThread
-
Hey guys,
I have the following situation:
I'm creating several objects in a separate thread via QtConcurrent.
When I'm done, I need this object to live in the main thread.I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.
What is the best way to achieve it?
-
Hey guys,
I have the following situation:
I'm creating several objects in a separate thread via QtConcurrent.
When I'm done, I need this object to live in the main thread.I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.
What is the best way to achieve it?
@themts said in How to move an object back to mainThread:
I tried "object->moveToThread(QApplication::instance()->thread());" but that doesn't work.
See https://doc.qt.io/qt-5/qobject.html#moveToThread -- "this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread."
-
that is clear.
I'm inside the QtConcurrent function and at the end I want to PUSH it to the mainThread.@themts said in How to move an object back to mainThread:
that is clear.
I'm inside the QtConcurrent function and at the end I want to PUSH it to the mainThread.OK, that sounds good.
Can you elaborate on what you mean by "that doesn't work"? What happens? How can you tell that it didn't work?