Qt 5.6 | Qt GUI | C++ Classes | QPlatformSystemTrayIcon

Qt 5.6.3 Reference Documentation

# QPlatformSystemTrayIcon Class

The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction. More...

Header: | #include <QPlatformSystemTrayIcon>
qmake: | QT += gui

- List of all members, including inherited members

## Public Types

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

## Public Functions

virtual void | cleanup() = 0
virtual QPlatformMenu * | createMenu() const
virtual QRect | geometry() const = 0
virtual void | init() = 0
virtual bool | isSystemTrayAvailable() const = 0
virtual void | showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs) = 0
virtual bool | supportsMessages() const = 0
virtual void | updateIcon(const QIcon &icon) = 0
virtual void | updateMenu(QPlatformMenu *menu) = 0
virtual void | updateToolTip(const QString &tooltip) = 0

## Signals

void | activated(QPlatformSystemTrayIcon::ActivationReason reason)
void | messageClicked()

## Detailed Description

The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction.

See also QSystemTrayIcon.

## Member Type Documentation

### enum QPlatformSystemTrayIcon::ActivationReason

This enum describes the reason the system tray was activated.

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

See also activated().

### enum QPlatformSystemTrayIcon::MessageIcon

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

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

See also updateIcon(), showMessage(), and QMessageBox.

## Member Function Documentation

### `[signal]` void QPlatformSystemTrayIcon::activated(QPlatformSystemTrayIcon::ActivationReason reason)

This signal is emitted when the user activates the system tray icon. reason specifies the reason for activation.

See also QSystemTrayIcon::ActivationReason.

### `[pure virtual]` void QPlatformSystemTrayIcon::cleanup()

This method is called to cleanup the platform dependent implementation.

### `[virtual]` QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const

This method is called in case there is no QPlatformMenu available when updating the menu. This allows the abstraction to provide a menu for the system tray icon even if normally a non-native menu is used.

The default implementation returns a null pointer.

This function was introduced in Qt 5.3.

See also updateMenu().

### `[pure virtual]` QRect QPlatformSystemTrayIcon::geometry() const

This method returns the geometry of the platform dependent system tray icon on the screen.

### `[pure virtual]` void QPlatformSystemTrayIcon::init()

This method is called to initialize the platform dependent implementation.

### `[pure virtual]` bool QPlatformSystemTrayIcon::isSystemTrayAvailable() const

Returns `true` if the system tray is available on the platform.

### `[signal]` void QPlatformSystemTrayIcon::messageClicked()

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

See also activated().

### `[pure virtual]` void QPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs)

Shows a balloon message for the entry with the given title, message msg and icon for the time specified in msecs. iconType is used as a hint for the implementing platform.

See also QSystemTrayIcon::showMessage().

### `[pure virtual]` bool QPlatformSystemTrayIcon::supportsMessages() const

Returns `true` if the system tray supports messages on the platform.

### `[pure virtual]` void QPlatformSystemTrayIcon::updateIcon(const QIcon &icon)

This method is called when the icon did change.

### `[pure virtual]` void QPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu)

This method is called when the system tray menu did change.

### `[pure virtual]` void QPlatformSystemTrayIcon::updateToolTip(const QString &tooltip)

This method is called when the tooltip text did change.