Favour invokeMethod or posting a custom event?
Unsolved
General and Desktop
-
I'm building a generic way to post a callback on the gui-thread from some background thread (i.e.: any non-gui thread). We have the wanted client-interface in place and a 'UiWorker', which is the
QObject
that will execute our callback, but there is one detail I can't quite decide upon.I can translate the different overloads into a generic function call (
std::function
), wrap that function object in a customQEvent
class and post the event object on the gui thread by posting it to the UiWorker. Or I do the same translation into a generic function call, but then pass this call to some fixed slot on the UiWorker, which I call usinginvokeMethod()
.Are there reasons to pick one or the other?