In many cases you may want to ensure that only one program or instance is running. In another word, if an instance of program is running and the user tries to run a new instance, you want to found that and exit second program and maybe show an appropriate message. You can implementated Qt only one program or instance is running problem in Qt with libraray qtsingleapplication.
The QtSingleApplication class provides an API to detect and communicate with running instances of an application. This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead.
This is an example how to create program with Qt only one program or instance is running with library qtsingleapplication (you can get other example in source code qtsingleapplication).
#include "runonlyone.h" //change with your include window application
int main(int argc, char *argv)
QtSingleApplication instance("qtsingleapplication sample", argc, argv);
if ( instance.sendMessage("is running application!") )
msgBox.setText("Your program is running.");
runOnlyOne w; //change with your window application
This is simple example hot to implementated Qt only one program or instance is running. With this library, you can create your program that can running only one program or instance in Qt.
qtsingleapplication is part of Qt Solution Archive. You can Download the complete of Qt Solution Archive source code at http://qt.gitorious.org/qt-solutions.Source : http://qt.nokia.com/products/qt-addons/solutions-archive/
My name is Toto Sugito. This is my notes when I try something. Maybe, this is NOT THE BEST SOLUTION for your problems. If you have other method or idea that better with my post, please share in this blog. Thank for visiting my site.