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
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
14QT_BEGIN_NAMESPACE
15
16
17class QSystemTrayIconPrivate;
18
19class QMenu;
20class QEvent;
21class QWheelEvent;
22class QMouseEvent;
23class QPoint;
24
25class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
26{
27 Q_OBJECT
28 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
29 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
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);
35 ~QSystemTrayIcon();
36
37 enum ActivationReason {
38 Unknown,
39 Context,
40 DoubleClick,
41 Trigger,
42 MiddleClick
43 };
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,
70 QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000);
71
72Q_SIGNALS:
73 void activated(QSystemTrayIcon::ActivationReason reason);
74 void messageClicked();
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
89QT_END_NAMESPACE
90
91#endif // QT_NO_SYSTEMTRAYICON
92#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:28
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