[PyQt] QSystemTrayIcon.activated weird Trigger behavior (PyQt 5.6) on Windows
Marius Shekow
marius.shekow at fit.fraunhofer.de
Mon Aug 22 13:33:22 BST 2016
Hi,
I have 2 issues with QSystemTrayIcon. I'm running Python 3.5.1 32-bit,
and PyQt 5.6 (with Qt 5.6) on Windows 7 x64.
1) I tested 2 different Windows 7 x64 machines, regarding detecting
single-click vs. double-click. On one machine, everything works as
expected. A single click gave me QSystemTrayIcon.Trigger, a double click
gave me QSystemTrayIcon.DoubleClick. On the other machine, however, a
double click would always first produce a Trigger followed by the
DoubleClick shortly after. On the machine where the behavior was as
expected, I discovered that I've never changed the Windows mouse double
click interval setting in my life. When I changed that setting, the
behavior became bad, like for the other machine (irreversible).
Regardless which value I'm setting the delay to, I can't get it back to
working as expected.
Following other people's advice, I'm using a disambiguation-timer, but
that is really just a hack and Qt should disambiguate this for me. Any
ideas?
2) I noticed that my slot for the activated-signal isn't called on a
single-click in the following situation:
Step 1: User opens the QMainWindow of my application (e.g. by
double-clicking the icon, or by using my tray icon context menu and
clicking on one of my QActions - both ways call
MyMainWindow.really_show_it())
MyMainWindow.really_show_it() call super().showNormal() and then
self.activateWindow(). Would I omit the latter, the window would not
come in the foreground if the user was working with a different
foreground application. Since the user explicitly asks for that window,
I consider it appropriate to force that it's shown by using
self.activateWindow()
Step 2 (optional): user closes the MainWindow, or minimizes it
Step 3: User performs a single-click on the tray icon. NOTHING happens.
At all. But my slot should be called. But it isn't.
Step 4: User repeats step 3: this time the signal is emitted (with
QSystemTrayIcon.Trigger, as expected)
Note: DoubleClick behavior is not affected, i.e. if you replace step 3
with "User peforms double click on the tray icon", then the
activated-signal is emitted with QSystemTrayIcon.DoubleClick, as expected.
I've read that other people had problems as well with this and they
suggested to catch the raw events. This doesn't work either. When I
create my own sub-class for QSystemTrayIcon and override the event()
method, it is never called, except for when I close my program (then I
get the delete event). I doubt that this is expected behavior.
I'm thankful for any input you can provide ;).
Cheers!
Marius
More information about the PyQt
mailing list