PDA

View Full Version : Best way to set focus to the application?



hakermania
6th September 2011, 11:36
Hello, when one instance of my program detects another instance it sends a message to the already running instance and it tries to strongly focus itself.
The code that does the focus is:


this->showNormal();
this->setFocusPolicy(Qt::StrongFocus);
this->setFocus();
this->raise();
this->setVisible(true);
this->activateWindow();

And all these in a row result to only a blinking minimize-bar, just like the program wants user's attention, but I need stronger focus, like go top of all the other windows.
How is this possible? Thanks!

stampede
10th September 2011, 09:34
You may want to check this thread : How to raise application from background (http://www.qtcentre.org/threads/38980-How-to-raise-application-from-background)

hakermania
19th January 2012, 19:25
Thanks for this, this post is old, but I (really) haven't solved this yet... The thread you specified was about Windows and I am working for ubuntu linux...

This is quite confusing, the system kind of recognized that a windows wants to come to the front but the window never shows itself. The only indication that something is happening is that current focused application loses focus... Nothing else actually...

wysota
19th January 2012, 19:50
Are you trying to focus an unfocused window or show a hidden/minimized one?