QSystemTrayIcon¶
The
QSystemTrayIcon
class provides an icon for an application in the system tray. More…
Synopsis¶
Functions¶
def
contextMenu
()def
geometry
()def
icon
()def
isVisible
()def
setContextMenu
(menu)def
setIcon
(icon)def
setToolTip
(tip)def
toolTip
()
Slots¶
def
hide
()def
setVisible
(visible)def
show
()def
showMessage
(title, msg, icon[, msecs=10000])def
showMessage
(title, msg[, icon=QSystemTrayIcon.Information[, msecs=10000]])
Signals¶
def
activated
(reason)def
messageClicked
()
Static functions¶
def
isSystemTrayAvailable
()def
supportsMessages
()
Detailed Description¶
Modern operating systems usually provide a special area on the desktop, called the system tray or notification area , where long-running applications can display icons and short messages.
The
QSystemTrayIcon
class can be used on the following platforms:
All supported versions of Windows.
All window managers and independent tray implementations for X11 that implement the http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html freedesktop.org XEmbed system tray specification.
All X11 desktop environments that implement the D-Bus http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem specification, including recent versions of KDE and Unity.
All supported versions of macOS .
To check whether a system tray is present on the user’s desktop, call the
isSystemTrayAvailable()
static function.To add a system tray entry, create a
QSystemTrayIcon
object, callsetContextMenu()
to provide a context menu for the icon, and callshow()
to make it visible in the system tray. Status notification messages (“balloon messages”) can be displayed at any time usingshowMessage()
.If the system tray is unavailable when a system tray icon is constructed, but becomes available later,
QSystemTrayIcon
will automatically add an entry for the application in the system tray if the icon isvisible
.The
activated()
signal is emitted when the user activates the icon.Only on X11, when a tooltip is requested, the
QSystemTrayIcon
receives aQHelpEvent
of typeToolTip
. Additionally, theQSystemTrayIcon
receives wheel events of typeWheel
. These are not supported on any other platform.
-
class
QSystemTrayIcon
([parent=None])¶ QSystemTrayIcon(icon[, parent=None])
- param parent
QObject
- param icon
QIcon
Constructs a
QSystemTrayIcon
object with the givenparent
.The icon is initially invisible.
See also
visible
Constructs a
QSystemTrayIcon
object with the givenicon
andparent
.The icon is initially invisible.
See also
visible
-
PySide2.QtWidgets.QSystemTrayIcon.
ActivationReason
¶ This enum describes the reason the system tray was activated.
Constant
Description
QSystemTrayIcon.Unknown
Unknown reason
QSystemTrayIcon.Context
The context menu for the system tray entry was requested
QSystemTrayIcon.DoubleClick
The system tray entry was double clicked.
Note
On macOS , a double click will only be emitted if no context menu is set, since the menu opens on mouse press
Constant
Description
QSystemTrayIcon.Trigger
The system tray entry was clicked
QSystemTrayIcon.MiddleClick
The system tray entry was clicked with the middle mouse button
See also
-
PySide2.QtWidgets.QSystemTrayIcon.
MessageIcon
¶ This enum describes the icon that is shown when a balloon message is displayed.
Constant
Description
QSystemTrayIcon.NoIcon
No icon is shown.
QSystemTrayIcon.Information
An information icon is shown.
QSystemTrayIcon.Warning
A standard warning icon is shown.
QSystemTrayIcon.Critical
A critical warning icon is shown.
See also
-
PySide2.QtWidgets.QSystemTrayIcon.
activated
(reason)¶ - Parameters
reason –
ActivationReason
-
PySide2.QtWidgets.QSystemTrayIcon.
contextMenu
()¶ - Return type
Returns the current context menu for the system tray entry.
See also
-
PySide2.QtWidgets.QSystemTrayIcon.
geometry
()¶ - Return type
QRect
Returns the geometry of the system tray icon in screen coordinates.
See also
visible
-
static
PySide2.QtWidgets.QSystemTrayIcon.
isSystemTrayAvailable
()¶ - Return type
bool
Returns
true
if the system tray is available; otherwise returnsfalse
.If the system tray is currently unavailable but becomes available later,
QSystemTrayIcon
will automatically add an entry in the system tray if it isvisible
.
-
PySide2.QtWidgets.QSystemTrayIcon.
isVisible
()¶ - Return type
bool
-
PySide2.QtWidgets.QSystemTrayIcon.
messageClicked
()¶
-
PySide2.QtWidgets.QSystemTrayIcon.
setContextMenu
(menu)¶ - Parameters
menu –
QMenu
Sets the specified
menu
to be the context menu for the system tray icon.The menu will pop up when the user requests the context menu for the system tray icon by clicking the mouse button.
On macOS , this is currenly converted to a NSMenu, so the aboutToHide() signal is not emitted.
Note
The system tray icon does not take ownership of the menu. You must ensure that it is deleted at the appropriate time by, for example, creating the menu with a suitable parent object.
See also
-
PySide2.QtWidgets.QSystemTrayIcon.
setVisible
(visible)¶ - Parameters
visible –
bool
See also
-
PySide2.QtWidgets.QSystemTrayIcon.
show
()¶ Shows the icon in the system tray.
See also
hide()
visible
-
PySide2.QtWidgets.QSystemTrayIcon.
showMessage
(title, msg[, icon=QSystemTrayIcon.Information[, msecs=10000]])¶ - Parameters
title – unicode
msg – unicode
icon –
MessageIcon
msecs –
int
-
PySide2.QtWidgets.QSystemTrayIcon.
showMessage
(title, msg, icon[, msecs=10000]) - Parameters
title – unicode
msg – unicode
icon –
QIcon
msecs –
int
-
static
PySide2.QtWidgets.QSystemTrayIcon.
supportsMessages
()¶ - Return type
bool
Returns
true
if the system tray supports balloon messages; otherwise returnsfalse
.See also
-
PySide2.QtWidgets.QSystemTrayIcon.
toolTip
()¶ - Return type
unicode
See also
© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.