Read for one instance. Run only one instance of the Qt application .
Apart from portability, if you are running Windows, another general approach is to create a named pipe (or named mutex ) when the application starts and destroys it before exiting. If the named pipe already exists, another instance is already running. You can even write to a named pipe by asking another instance to bring its window to the foreground, although the console application may not use it specifically.
Another way to focus an existing instance is to find the window of the already running instance, then call SetFocus on its HWND or the corresponding function on your platform.
source share