How to get focus on First instance of an application using QSharedMemory
-
how can we make a single instance application using QSharedmemory. when we try to run for another instance, first instance should get focus and it's window become top window.I want to do it Without using socket or timer.
Any Help will be appreciated. -
Hi,
Did you try QtSingleApplication ?
-
Hi Gaist, this is from I am Sumit. Yes, I have tried QtSingleApplication. but still i didn't get focus on first instance . And i m looking for a method rather than using socket or timer.
Any body have such kind of method. Please suggest me .
-
Are you sure you used QtSingleApplication correctly ? That's what "setActivationWindow":http://doc.qt.digia.com/solutions/4/qtsingleapplication/qtsingleapplication.html#setActivationWindow should do
-
Hi! Gaist. Yes. I have done it using QtSingleApplication and it is working fine. but i want to do it in some other way. Since QtSingleApplication is using socket. and i don't want to use socket or timer. Is it possible to do it in some other way.
-
What is the problem with sockets ?
-
Actually, I forced to do it using QSharedmemory and *without using socket *. Reason may be possible that socket or timer increase the CPU usage little bit. and we are not supposed to provide CPU to this task since CPU is already very busy in some other important tasks.
Is it possible using QSharedMemory. is there any such SIGNAL available in QSharedMemory which can emit as soon as second instance present.
-
There's no such signal for that, you'll have to implement all the logic yourself. Probably something like polling the memory thus waste CPU cycles for that.
-
Now i m storing the winId into QSharedMemory. and i m hoping to getfocus on that window which has this winId in the execution of second instance. but the problem is that SharedMemory::data is not showing correct value. so how can i get correct value stored in sharedMemory at the time of execution of first instance.
It is showing ÝÝÝÝÝÝÝ . I don't know what is that. Please help.
-
AnyOne ???