Qt: Best practice for a single instance app protection

Simple solution, that does what you want. Without network dependency (as QtSingleApplication) and without any overhead. Usage: int main() { RunGuard guard( “some_random_key” ); if ( !guard.tryToRun() ) return 0; QAppplication a(/*…*/); // … } RunGuard.h #ifndef RUNGUARD_H #define RUNGUARD_H #include <QObject> #include <QSharedMemory> #include <QSystemSemaphore> class RunGuard { public: RunGuard( const QString& key ); … Read more