Check if application is running
-
Qt has a range IPC solutions available check the following:
- "Inter-Process Communication in Qt":http://qt-project.org/doc/qt-4.8/ipc.html
- "QtSingleApplication":http://doc.qt.digia.com/solutions/4/qtsingleapplication/qtsingleapplication.html
The first is a reference to all the standard ways of communicating between two programs (QLocalServer/Socket being the easiest and most portable IMHO). The second is a special subclass of the QApplication that only allows a single instance of the application to be running at one time and therefore makes it easy to get a handle to that instance.
Hope this helps ;o)
-
... or better use "QSystemSemaphore":http://qt-project.org/doc/qt-5/qsystemsemaphore.html
QSystemSemaphore can be accessed from multiple processes
-
-
QtSingleApplication is useful here if you want to start App2 if and only if it isn't running already... App1 can just spawn the process and be sure either way that the App2 is running. I've done this in the past quite successfully. I would advocate the IPC solution if you want the two apps to communicate however.
-
Where is <QtSingleApplication>? I've got qt5 installed on my debian linux wheezy system and I get a "file not found" message when I say:
#include <QtSingleApplication>
-
On "gitorious":https://qt.gitorious.org/qt-solutions :)