Basically, the other answers already contain all of my thoughts. But, since I've been mentioned I'll still chime in.
In a single-threaded context I can just call functions and that's fine. In a multi-threaded context when I want to call functions of an object that lives in a different thread (especially if you want to call GUI functions in Qt) invokeMethod() is the only easy way I know of. Sure, you can properly set up a signal. I personally don't see the point in having a signal (which I then need to connect) if it is called from just a single place in the code. First, I have to come up with an appropriate name for the signal, and second, I'll have a long list of signals in the class declaration that are of no interest to any outsider.
The use case of of using this to call functions belonging to a GUI thread is so pervasive that I have a header-only library that (among other things) has a function guiThread(...) (https://github.com/SimonSchroeder/QtThreadHelper) to easily place calls into the GUI thread from other threads. From the recent discussion in this forum I have also learned that invokeMethod() takes a connection type as argument. I guess, then my function guiThreadMaybe() is not necessary, as the default is the AutoConnection which will do already a direct call if it is from the same thread (the 'maybe' part explicitly checks for that).
Outside of multi-threading I only see a single use case for invokeMethod(): If I don't want to immediately execute that function, but put it in the event queue to be executed at a later point. I guess this is a valid use case, but not one I encounter often. In many cases, the suggested solution is a single shot timer with a timeout of 0ms. In addition to putting this call into the event loop, it will also only execute once the event loop is otherwise idle.
@JonB said in Relevance of invokeMethod() in multithreaded programs:
I didn't see why there is a particular mention here of separate threads.
It wasn't mentioned in the original post, but later:
@Christian-Ehrlicher said in Show a QMessage box from the context of a function defined outside mainwindow.cpp:
One problem with a simple callback will arise when you run the solver in a different thread.
"invokeMethod() is also my general solution if I'm multithreaded" needs to be read in the context of the original discussion: It was specifically about calling GUI functions. If we combine that with multithreading, invokeMethod() is the (hard-to-find) obvious solution.