PDA

View Full Version : lost Focus with QProcess



Jora
7th March 2012, 19:45
Hello!
I have a program that performs a function as a dispatcher, and launches other applications (3-4) by QProcess.
The applications runs in full screen mode. And all the time the user can be seen only one application. Switching between them is realized through the pipe.
Thus, when we switch, one application is hidden (setvisible (false)) else just appears (setvisible (true)).
Sometimes! focus is lost, and the running application is not responding to keystrokes.
I tried do setFocus (),
setActivateWindow () (the documentation says that the application should be in the top level but this did not occur)
tried to implement window activation and set focus by a library X11, but also useless.
It is noteworthy that sometimes the focus of work, and sometimes not.
Tested on Ubuntu 10.04, 10.10, 11.10 (x86, x64). Everywhere one and the same problem. Version of Qt 4.7.4
Tell me what i can do here?
thanks in advance

Spitfire
8th March 2012, 14:56
You can't set focus (nor activate window) on a widget unless it's visible.
As X11 is asynchronous I'm guessing that sometimes setFocus()/activateWindow() is processed faster than show().
Use single shot timer with short delay to activate/set focus on the window.