amleto
I am concerned about how you will pass the new result to worker2 in this example, though.
I just could give the finished signal a QString parameter and pass this to the destiny slot...
What i dont really understand is this:
// All the membervars which was created in the cTor without the (this)parent wont be moved to the new thread right?
// that mean for example: membervar in the header file: int m_Test ;
// cTor (cpp file) -> m_Test = 5; or in the init list m_test(5)
obj->moveToThread(&t1);
QThread t1;
// All the membervars which was created in the cTor without the (this)parent wont be moved to the new thread right?
// that mean for example: membervar in the header file: int m_Test ;
// cTor (cpp file) -> m_Test = 5; or in the init list m_test(5)
QObject *obj = new QObject;
obj->moveToThread(&t1);
To copy to clipboard, switch view to plain text mode
So if i create membervars and use movetoThread -> must i set the parent to all my membervars (all who inherit qobject) to the currentclass (this)?
Cause if i dont do this, the membervars are created in the mainthread for e.g and wont be moved to the new thread, so this maybe a problem right?
If i use Threads without subclassing, i have to take care "where" i run the methods of the object, that mean if i am not in the right thread i have to run the methods via connect().(they have to be a slot then)
I read s.th about QMetaObject::invoke.
//the current thread is not the workerThread so calling this way of the slot is safe?
QMetaObject::invokeMethod(pWorkersender,
"slotName",Qt
::AutoConnection);
//instead pWorkersender->slotName()
//the current thread is not the workerThread so calling this way of the slot is safe?
QMetaObject::invokeMethod(pWorkersender, "slotName",Qt::AutoConnection); //instead pWorkersender->slotName()
To copy to clipboard, switch view to plain text mode
Is this use of invokeMethod threadsafe? that mean can i call this way a slot without being afraid of getting problems?
Thanks again for all ur help, really great answers!
Bookmarks