Session manager seems not to be the right tool to do so,according to what's written in the assistant.
Well,real inter-process comunnication (I'm mean some that can withstand all conditions mentioned by squidge) provides DBus,QCOPChannel and TCP/IP.But according to mentalmushroom's description of OS something aviable for windows is needed,so it left only TCP/IP for consideration.Well,my idea then is somesuch:
thats still shoud be:
//do not allow to running multiple instances of the application
QSharedMemory mem("SomeUniquekeyNameThere");
if(!mem.create(1))
{
QMessageBox::critical(0,
"Instance detected!",
"The application is already running!\nApplication terminating...",
"Ok");
//pseudocode now
send UDP datagram with let's say "SomeUniquekeyNameThere"
anyway,using datagram you may invent many cases for many purposes,not only activating currently running app's window.
exit(0);
}
else
{
//pseudocode now
create
QUdpSocket on 127.0.0.1 and
connect it
's readyRead signal to some slot in your main window class}
yourMainWindowClass::yourSlotReadingUDPDatagrams
{
//you've received SomeUniquekeyNameThere->use activateWindow
//and other desired behaviours
}
thats still shoud be:
//do not allow to running multiple instances of the application
QSharedMemory mem("SomeUniquekeyNameThere");
if(!mem.create(1))
{
QMessageBox::critical(0,"Instance detected!","The application is already running!\nApplication terminating...","Ok");
//pseudocode now
send UDP datagram with let's say "SomeUniquekeyNameThere"
anyway,using datagram you may invent many cases for many purposes,not only activating currently running app's window.
exit(0);
}
else
{
//pseudocode now
create QUdpSocket on 127.0.0.1 and connect it's readyRead signal to some slot in your main window class
}
yourMainWindowClass::yourSlotReadingUDPDatagrams
{
//you've received SomeUniquekeyNameThere->use activateWindow
//and other desired behaviours
}
To copy to clipboard, switch view to plain text mode
Shame on me I didn't saw the sentence about activationg the application window,I tougth the autor wants only prevent the other instances from running :/
Bookmarks