If i invoke QMetaObject::invokeMethod from thread to singletone is the invokation is still in that thread?
i have thread (working great ) that invoking method in singletone object like this:
@bool bInvokeUpdate= QMetaObject::invokeMethod(ApiManager::getInstance(),
im using Qt::BlockingQueuedConnection so i can continue the thread work based on bool value .. any way
my question is dose this invocation remains in the thread ? or it cause to method to be preformed in the main thread ?
quick update ...
when i debug the app when im in the thread i see in the debugger that im in thread id xxxx
but when i set breakpoint in the updateMainWindowTree method , i see it jumping to the mainthread .
so what does it mean that i keep invoking functions from the main thread ? how can i avoid it?
The code runs in the thread the singleton belongs to, which is either the thread it was created (most probably the main thread) or moved to (using QObject::moveToThread()).
As judging from your method name <code>updateMainWindowTree</code> one should mention that you cannot do any GUI related operations outside the main thread. This includes updating any widgets.
what about if i "emit" SIGNAL from Thread to GUI main thread ?
what is better to use "emit" or QMetaObject::invokeMethod
to update GUI , yes i know is abit different question .
You can of course trigger the update from another thread, provided that the update itself runs in the main thread.
There is no difference between emit and QMetaObject::invokeMethod(), besides that emit invokes all connected methods whereas QMetaObject::invokeMethod() invokes just a single method.
Thanks for the insight! Im current trying to figure out why my app goes boom (newbie programmer) and I did not realize that about QMetaObject::InvokeMethod.