Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsystemtrayicon.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSYSTEMTRAYICON_H
5#define QSYSTEMTRAYICON_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qobject.h>
9
10#ifndef QT_NO_SYSTEMTRAYICON
11
12#include <QtGui/qicon.h>
13
15
16
18
19class QMenu;
20class QEvent;
21class QWheelEvent;
22class QMouseEvent;
23class QPoint;
24
25class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
26{
28 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
30 Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
31
32public:
33 QSystemTrayIcon(QObject *parent = nullptr);
34 QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr);
36
44
45#if QT_CONFIG(menu)
46 void setContextMenu(QMenu *menu);
47 QMenu *contextMenu() const;
48#endif
49
50 QIcon icon() const;
51 void setIcon(const QIcon &icon);
52
53 QString toolTip() const;
54 void setToolTip(const QString &tip);
55
56 static bool isSystemTrayAvailable();
57 static bool supportsMessages();
58
59 enum MessageIcon { NoIcon, Information, Warning, Critical };
60
61 QRect geometry() const;
62 bool isVisible() const;
63
64public Q_SLOTS:
65 void setVisible(bool visible);
66 inline void show() { setVisible(true); }
67 inline void hide() { setVisible(false); }
68 void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs = 10000);
69 void showMessage(const QString &title, const QString &msg,
71
75
76protected:
77 bool event(QEvent *event) override;
78
79private:
80 Q_DISABLE_COPY(QSystemTrayIcon)
81 Q_DECLARE_PRIVATE(QSystemTrayIcon)
82
83 Q_PRIVATE_SLOT(d_func(), void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason))
84
85 friend class QSystemTrayIconSys;
86 friend class QBalloonTip;
87};
88
90
91#endif // QT_NO_SYSTEMTRAYICON
92#endif // QSYSTEMTRAYICON_H
\inmodule QtCore
Definition qcoreevent.h:45
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
ActivationReason
This enum describes the reason the system tray was activated.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QSystemTrayIcon class provides an icon for an application in the system tray.
void activated(QSystemTrayIcon::ActivationReason reason)
This signal is emitted when the user activates the system tray icon.
ActivationReason
This enum describes the reason the system tray was activated.
MessageIcon
This enum describes the icon that is shown when a balloon message is displayed.
void messageClicked()
This signal is emitted when the message displayed using showMessage() was clicked by the user.
void show()
Shows the icon in the system tray.
void hide()
Hides the system tray entry.
Combined button and popup list for selecting options.
struct _cl_event * event
decorationRoleName setToolTip
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QString title
[35]
edit isVisible()
myAction setIcon(SomeIcon)
QMenu menu
[5]
splash showMessage("Loaded modules")