There is one GUI application (host) and one plugin application. I need to run some code from the plugin in the main thread of the host application. I also do not have access to the source code of the host application. On a Mac, this is possible through performSelectorOnMainThread. In Win, we can set the hook, and then send a message. But what about Linux?
Long story:
The host application can use the plugin in two ways: directly in the main thread (via the click button) and in some processes in another thread. A plugin is a Qt-based application, and qApp should always be created in the main thread (to avoid some problems), but this does not happen in the second case. On Win and Mac, this problem has already been solved by calling the creation code in the main thread (as I wrote above). I am looking for a similar way to do this on Linux.
Update Finally, I found a solution to this problem using the host API. Unfortunately, there is no reliable guarantee, as the implementation may differ for another host (despite the documentation). But for basic cases, it works well. The question is still relevant, by the way.
source share