To solve look at examples in SingleApplication package :
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
// below is the magic code
SingleApplication instance("TrivialExample", &app);
if(instance.isRunning())
{
QString message
= "Hello! Did You hear other Trivial Example instance? :)\n" "PID: " + QString::number(app.
applicationPid());
if(instance.sendMessage(message))
return 0;
}
QApplication app(argc, argv);
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
// below is the magic code
SingleApplication instance("TrivialExample", &app);
if(instance.isRunning())
{
QString message = "Hello! Did You hear other Trivial Example instance? :)\n"
"PID: " + QString::number(app.applicationPid());
if(instance.sendMessage(message))
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks