Favour invokeMethod or posting a custom event?



  • 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 custom QEvent 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 using invokeMethod().

    Are there reasons to pick one or the other?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.