|  | Home · All Classes · Modules

# QSystemTrayIcon Class Reference
[QtGui module]

The QSystemTrayIcon class provides an icon for an application in the system tray. More...

Inherits QObject.

### Types

- enum ActivationReason { Unknown, Context, DoubleClick, Trigger, MiddleClick }
- enum MessageIcon { NoIcon, Information, Warning, Critical }

### Methods

- __init__ (self, QObject parent = None)
- __init__ (self, QIcon icon, QObject parent = None)
- QMenu contextMenu (self)
- bool event (self, QEvent event)
- QRect geometry (self)
- hide (self)
- QIcon icon (self)
- bool isVisible (self)
- setContextMenu (self, QMenu menu)
- setIcon (self, QIcon icon)
- setToolTip (self, QString tip)
- setVisible (self, bool visible)
- show (self)
- showMessage (self, QString title, QString msg, MessageIcon icon = QSystemTrayIcon.Information, int msecs = 10000)
- QString toolTip (self)

### Static Methods

- bool isSystemTrayAvailable ()
- bool supportsMessages ()

### Qt Signals

- void activated ( ::QSystemTrayIcon::ActivationReason)
- void messageClicked ()

## Detailed Description

The QSystemTrayIcon class provides an icon for an application in the system tray.

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 for X11 that implement the freedesktop.org system tray specification, including recent versions of KDE and GNOME.
- All supported versions of Mac OS X. Note that the Growl notification system must be installed for QSystemTrayIcon.showMessage() to display messages.

To check whether a system tray is present on the user's desktop, call the QSystemTrayIcon.isSystemTrayAvailable() static function.

To add a system tray entry, create a QSystemTrayIcon object, call setContextMenu() to provide a context menu for the icon, and call show() to make it visible in the system tray. Status notification messages ("balloon messages") can be displayed at any time using showMessage().

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 is visible.

The activated() signal is emitted when the user activates the icon.

Only on X11, when a tooltip is requested, the QSystemTrayIcon receives a QHelpEvent of type QEvent.ToolTip. Additionally, the QSystemTrayIcon receives wheel events of type QEvent.Wheel. These are not supported on any other platform.

## Type Documentation

### QSystemTrayIcon.ActivationReason

This enum describes the reason the system tray was activated.

Constant | Value | Description
--- | --- | ---
`QSystemTrayIcon.Unknown` | `0` | Unknown reason
`QSystemTrayIcon.Context` | `1` | The context menu for the system tray entry was requested
`QSystemTrayIcon.DoubleClick` | `2` | The system tray entry was double clicked
`QSystemTrayIcon.Trigger` | `3` | The system tray entry was clicked
`QSystemTrayIcon.MiddleClick` | `4` | The system tray entry was clicked with the middle mouse button

See also activated().

### QSystemTrayIcon.MessageIcon

This enum describes the icon that is shown when a balloon message is displayed.

Constant | Value | Description
--- | --- | ---
`QSystemTrayIcon.NoIcon` | `0` | No icon is shown.
`QSystemTrayIcon.Information` | `1` | An information icon is shown.
`QSystemTrayIcon.Warning` | `2` | A standard warning icon is shown.
`QSystemTrayIcon.Critical` | `3` | A critical warning icon is shown.

See also QMessageBox.

## Method Documentation

### QSystemTrayIcon.__init__ (self, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QSystemTrayIcon object with the given parent.

The icon is initially invisible.

See also visible.

### QSystemTrayIcon.__init__ (self, QIcon icon, QObject parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QSystemTrayIcon object with the given icon and parent.

The icon is initially invisible.

See also visible.

### QMenu QSystemTrayIcon.contextMenu (self)

Returns the current context menu for the system tray entry.

See also setContextMenu().

### bool QSystemTrayIcon.event (self, QEvent event)

Reimplemented from QObject.event().

### QRect QSystemTrayIcon.geometry (self)

Returns the geometry of the system tray icon in screen coordinates.

This function was introduced in Qt 4.3.

See also visible.

### QSystemTrayIcon.hide (self)

This method is also a Qt slot with the C++ signature `void hide()`.

Hides the system tray entry.

See also show() and visible.

### QIcon QSystemTrayIcon.icon (self)

### bool QSystemTrayIcon.isSystemTrayAvailable ()

Returns true if the system tray is available; otherwise returns false.

If the system tray is currently unavailable but becomes available later, QSystemTrayIcon will automatically add an entry in the system tray if it is visible.

### bool QSystemTrayIcon.isVisible (self)

### QSystemTrayIcon.setContextMenu (self, QMenu menu)

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 Mac OS X, 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 contextMenu().

### QSystemTrayIcon.setIcon (self, QIcon icon)

### QSystemTrayIcon.setToolTip (self, QString tip)

### QSystemTrayIcon.setVisible (self, bool visible)

This method is also a Qt slot with the C++ signature `void setVisible(bool)`.

### QSystemTrayIcon.show (self)

This method is also a Qt slot with the C++ signature `void show()`.

Shows the icon in the system tray.

See also hide() and visible.

### QSystemTrayIcon.showMessage (self, QString title, QString msg, MessageIcon icon = QSystemTrayIcon.Information, int msecs = 10000)

Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint. title and message must be plain text strings.

Message can be clicked by the user; the messageClicked() signal will emitted when this occurs.

Note that display of messages are dependent on the system configuration and user preferences, and that messages may not appear at all. Hence, it should not be relied upon as the sole means for providing critical information.

On Windows, the millisecondsTimeoutHint is usually ignored by the system when the application has focus.

On Mac OS X, the Growl notification system must be installed for this function to display messages.

This function was introduced in Qt 4.3.

See also show() and supportsMessages().

### bool QSystemTrayIcon.supportsMessages ()

Returns true if the system tray supports balloon messages; otherwise returns false.

See also showMessage().

### QString QSystemTrayIcon.toolTip (self)

## Qt Signal Documentation

### void activated ( ::QSystemTrayIcon::ActivationReason)

This is the default overload of this signal.

This signal is emitted when the user activates the system tray icon. reason specifies the reason for activation. QSystemTrayIcon.ActivationReason enumerates the various reasons.

See also QSystemTrayIcon.ActivationReason.

### void messageClicked ()

This is the default overload of this signal.

This signal is emitted when the message displayed using showMessage() was clicked by the user.

Currently this signal is not sent on Mac OS X.

Note: We follow Microsoft Windows XP/Vista behavior, so the signal is also emitted when the user clicks on a tray icon with a balloon message displayed.

See also activated().