Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QSystemTrayIcon Class Reference

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

 #include <QSystemTrayIcon>

Inherits: QObject.

This class was introduced in Qt 4.2.

Public Types

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

Properties

  • 1 property inherited from QObject

Public Functions

QSystemTrayIcon ( QObject * parent = 0 )
QSystemTrayIcon ( const QIcon & icon, QObject * parent = 0 )
~QSystemTrayIcon ()
QMenu * contextMenu () const
QRect geometry () const
QIcon icon () const
bool isVisible () const
void setContextMenu ( QMenu * menu )
void setIcon ( const QIcon & icon )
void setToolTip ( const QString & tip )
void showMessage ( const QString & title, const QString & message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000 )
QString toolTip () const
  • 29 public functions inherited from QObject

Public Slots

void hide ()
void setVisible ( bool visible )
void show ()
  • 1 public slot inherited from QObject

Signals

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

Static Public Members

bool isSystemTrayAvailable ()
bool supportsMessages ()
  • 5 static public members inherited from QObject

Reimplemented Protected Functions

virtual bool event ( QEvent * e )
  • 7 protected functions inherited from QObject

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 system tray on Windows XP.

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.

See also QDesktopServices, QDesktopWidget, Desktop Integration, and System Tray Icon Example.

Member Type Documentation

enum QSystemTrayIcon::ActivationReason

This enum describes the reason the system tray was activated.

ConstantValueDescription
QSystemTrayIcon::Unknown0Unknown reason
QSystemTrayIcon::Context1The context menu for the system tray entry was requested
QSystemTrayIcon::DoubleClick2The system tray entry was double clicked
QSystemTrayIcon::Trigger3The system tray entry was clicked
QSystemTrayIcon::MiddleClick4The system tray entry was clicked with the middle mouse button

See also activated().

enum QSystemTrayIcon::MessageIcon

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

ConstantValueDescription
QSystemTrayIcon::NoIcon0No icon is shown.
QSystemTrayIcon::Information1An information icon is shown.
QSystemTrayIcon::Warning2A standard warning icon is shown.
QSystemTrayIcon::Critical3A critical warning icon is shown.

See also QMessageBox.

Property Documentation

icon : QIcon

This property holds the system tray icon.

On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary.

Access functions:

QIcon icon () const
void setIcon ( const QIcon & icon )

toolTip : QString

This property holds the tooltip for the system tray entry.

On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.

Access functions:

QString toolTip () const
void setToolTip ( const QString & tip )

visible : bool

This property holds whether the system tray entry is visible.

Setting this property to true or calling show() makes the system tray icon visible; setting this property to false or calling hide() hides it.

Access functions:

bool isVisible () const
void setVisible ( bool visible )

Member Function Documentation

QSystemTrayIcon::QSystemTrayIcon ( QObject * parent = 0 )

Constructs a QSystemTrayIcon object with the given parent.

The icon is initially invisible.

See also visible.

QSystemTrayIcon::QSystemTrayIcon ( const QIcon & icon, QObject * parent = 0 )

Constructs a QSystemTrayIcon object with the given icon and parent.

The icon is initially invisible.

See also visible.

QSystemTrayIcon::~QSystemTrayIcon ()

Removes the icon from the system tray and frees all allocated resources.

void QSystemTrayIcon::activated ( QSystemTrayIcon::ActivationReason reason ) [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.

QMenu * QSystemTrayIcon::contextMenu () const

Returns the current context menu for the system tray entry.

See also setContextMenu().

bool QSystemTrayIcon::event ( QEvent * e ) [virtual protected]

Reimplemented from QObject::event().

QRect QSystemTrayIcon::geometry () const

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

This function was introduced in Qt 4.3.

See also visible.

void QSystemTrayIcon::hide () [slot]

Hides the system tray entry.

See also show() and visible.

bool QSystemTrayIcon::isSystemTrayAvailable () [static]

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.

void QSystemTrayIcon::messageClicked () [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().

void QSystemTrayIcon::setContextMenu ( 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().

void QSystemTrayIcon::show () [slot]

Shows the icon in the system tray.

See also hide() and visible.

void QSystemTrayIcon::showMessage ( const QString & title, const QString & message, MessageIcon icon = Information, int millisecondsTimeoutHint = 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 () [static]

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

See also showMessage().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 68
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique PyQt/PySide a besoin de vous ! 0
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenGL

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web