Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QSYSTEMTRAYICON_H
6#define QSYSTEMTRAYICON_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10
11#ifndef QT_NO_SYSTEMTRAYICON
12
13#include <QtGui/qicon.h>
14
15QT_BEGIN_NAMESPACE
16
17
18class QSystemTrayIconPrivate;
19
20class QMenu;
21class QEvent;
22class QWheelEvent;
23class QMouseEvent;
24class QPoint;
25
26class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
30 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
31 Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
32
33public:
34 QSystemTrayIcon(QObject *parent = nullptr);
35 QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr);
36 ~QSystemTrayIcon();
37
38 enum ActivationReason {
39 Unknown,
40 Context,
41 DoubleClick,
42 Trigger,
43 MiddleClick
44 };
45
46#if QT_CONFIG(menu)
47 void setContextMenu(QMenu *menu);
48 QMenu *contextMenu() const;
49#endif
50
51 QIcon icon() const;
52 void setIcon(const QIcon &icon);
53
54 QString toolTip() const;
55 void setToolTip(const QString &tip);
56
57 static bool isSystemTrayAvailable();
58 static bool supportsMessages();
59
60 enum MessageIcon { NoIcon, Information, Warning, Critical };
61
62 QRect geometry() const;
63 bool isVisible() const;
64
65public Q_SLOTS:
66 void setVisible(bool visible);
67 inline void show() { setVisible(true); }
68 inline void hide() { setVisible(false); }
69 void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs = 10000);
70 void showMessage(const QString &title, const QString &msg,
71 QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000);
72
73Q_SIGNALS:
74 void activated(QSystemTrayIcon::ActivationReason reason);
75 void messageClicked();
76
77protected:
78 bool event(QEvent *event) override;
79
80private:
81 Q_DISABLE_COPY(QSystemTrayIcon)
82 Q_DECLARE_PRIVATE(QSystemTrayIcon)
83
84 Q_PRIVATE_SLOT(d_func(), void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason))
85
86 friend class QSystemTrayIconSys;
87 friend class QBalloonTip;
88};
89
90QT_END_NAMESPACE
91
92#endif // QT_NO_SYSTEMTRAYICON
93#endif // QSYSTEMTRAYICON_H
static void hideBalloon()
static bool isBalloonVisible()
static void updateBalloonPosition(const QPoint &pos)
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
\inmodule QtGui
Definition qbitmap.h:16
QPainter(QPaintDevice *)
Constructs a painter that begins painting the paint device immediately.
\inmodule QtCore\reentrant
Definition qpoint.h:29
void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason)
QPlatformSystemTrayIcon * qpa_sys
The QSystemTrayIcon class provides an icon for an application in the system tray.
static QBalloonTip * theSolitaryBalloonTip