[PyQt] PyQt5 system tray icon context menu strange behavior

flll at seznam.cz flll at seznam.cz
Fri Jun 30 12:00:06 BST 2017

Hello all,

I have noticed that system tray icon's (QSystemTrayIcon) context menu 
(QMenu) is behaving strangely. 

1) When tray icon's context menu is closed, it does not emit signal 
aboutToHide(), even though it should (https://doc.qt.io/qt-5/qmenu.html#

2) The context menu does not react to move(). It sticks to tray icon at the 
same place as it appeared. That is a problem if menu has been updated and 
the new content is bigger. The menu adjusts its size properly, but does not 
change its position (is fixed to its original left border), so a part of the
updated larger menu is displayed "out of the screen" and is not visible.

3) When tray icon is clicked and menu displayed, calling tray_icon.
contextMenu().isHidden() returns True (hidden), even though it is definitely
visible. While tray icon's menu is displayed, calling menu.show() displayes 
another copy of the same menu somewhere on the screen (on its default or 
predefined position). When the copy is displayed, the menu correctly states 
"isHidden() == False" and the copy can be moved by "move()".

It looks like the tray icon's context menu is in some strange relation with 
the tray icon. It looks really confusing to me. Plus it makes nearly 
impossible to use the menu for something more than just a few static options
(can not clear old content when menu is hidden, updated menu is not 
visible...). Is this intended behaviour?

Best regards, Filip Happy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170630/7c111921/attachment.html>

More information about the PyQt mailing list