I have a potentially long-running task (serialise a document) which I don't want to run in the Gui thread. At the end of that task I want to update various visual aspects of the UI (menu enablement, etc.).
I had assumed that QTimer.singleShot() was the way to go, and that the method it runs would always execute in the Gui thread. But this turns out not to be so: if you call it in a non-Gui thread, its invoked method runs in a non-Gui thread (the same one).
I have double-checked this on my OS (W10). If you find that this is not the case on yours I'd be interested to hear about it.
I've actually created a decorator to check that every method in my app runs in the right thread (Gui or non-Gui). There are one or two where the parameter is None (= can be either) but these are very few. The method which updates the UI elements MUST be called in the Gui thread.
I can of course do this by creating a new signal and firing that. Is there not a simpler way of doing it?
The answer to this appears to be No (see Musicamante's comments).
I'm not sure whether to delete this question. I think it clarifies things for me.
How to call method in gui (application) thread from method in non-gui thread?