[PyQt] how to give the focus to my Qt-window (kde4)

Bastian Weber bastian.weber at gmx-topmail.de
Sun Dec 6 16:55:33 GMT 2009


Hello Qt-List,

I've written a small app that most of the time runs minimized to the
systemtray and waits for a dbus signal to show its main dialog. It is
strongly based on this recipe: http://paste.pocoo.org/show/42329/

Now I have the following behavior: when I click on the systray icon the
main dialog appears in front of all other open windows. Thats fine. But
when I press the keyboard shortcut which generates the dbus signal
(configured via kcmshell4 khotkeys) the main dialog appears (I use
'self.setVisible(self.isHidden())') in background and needs a mouse
click to get the focus.

How can I grant the focus automatically to that window? (Or how can my
app steal the focus from other windows)

If I configure the focus stealing prevention level to 'None' it works as
I want, but thats not a good solution, because other apps may steal the
focus too.

I need to set something like a 'focus steal authority level'.

(I use KDE KDE4.3.2 (Kubuntu 9.10))


Thanks and kind regards,
Bastian.


More information about the PyQt mailing list