I do not think that you can only do this reliably with the Qt API.
There are several solutions for windows. For instance. here , and here , and here .
The method that I used earlier is to declare a shared memory section and write a handle to the application window handle. Later, when the second instance of your program starts, you can find the handle to the window of the first and activate it.
I don’t think you have a problem with Windows so that you don’t do this in this case, because your second instance is an active application, therefore it is allowed to “transfer focus” to other windows.
source share