内容表

上一话题

QSwipeGesture

下一话题

QTabBar

QSystemTrayIcon

QSystemTrayIcon class provides an icon for an application in the system tray. 更多

Inheritance diagram of PySide2.QtWidgets.QSystemTrayIcon

概要

函数

信号

详细描述

现代操作系统通常在桌面提供特殊区域,称为 系统托盘 or 通知区域 ,在那里长时间运行应用程序可以显示图标和短消息。

../../_images/system-tray.png

QSystemTrayIcon class can be used on the following platforms:

To check whether a system tray is present on the user’s desktop, call the 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 .

activated() signal is emitted when the user activates the icon.

Only on X11, when a tooltip is requested, the QSystemTrayIcon 接收 QHelpEvent of type ToolTip . Additionally, the QSystemTrayIcon receives wheel events of type Wheel 。这些不被支持,在任何其它平台。

class QSystemTrayIcon ( [ parent=None ] )

QSystemTrayIcon(icon[, parent=None])

param parent

QObject

param icon

QIcon

构造 QSystemTrayIcon 对象采用给定 parent .

图标最初是不可见的。

另请参阅

visible

构造 QSystemTrayIcon 对象采用给定 icon and parent .

图标最初是不可见的。

另请参阅

visible

PySide2.QtWidgets.QSystemTrayIcon. ActivationReason

此枚举描述系统托盘被激活的原因。

常量

描述

QSystemTrayIcon.Unknown

未知原因

QSystemTrayIcon.Context

用于系统托盘条目的上下文菜单被请求

QSystemTrayIcon.DoubleClick

系统托盘条目被双击。

注意

On macOS, a double click will only be emitted if no context menu is set, since the menu opens on mouse press

常量

描述

QSystemTrayIcon.Trigger

系统托盘条目被点击

QSystemTrayIcon.MiddleClick

系统托盘条目被点击,采用鼠标中键

另请参阅

activated()

PySide2.QtWidgets.QSystemTrayIcon. MessageIcon

此枚举描述展示图标,当显示气球消息时。

常量

描述

QSystemTrayIcon.NoIcon

没有展示图标。

QSystemTrayIcon.Information

展示信息图标。

QSystemTrayIcon.Warning

展示标准警告图标。

QSystemTrayIcon.Critical

展示严重警告图标。

另请参阅

QMessageBox

PySide2.QtWidgets.QSystemTrayIcon. activated ( reason )
参数

reason ActivationReason

PySide2.QtWidgets.QSystemTrayIcon. contextMenu ( )
返回类型

QMenu

Returns the current context menu for the system tray entry.

另请参阅

setContextMenu()

PySide2.QtWidgets.QSystemTrayIcon. geometry ( )
返回类型

QRect

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

另请参阅

visible

PySide2.QtWidgets.QSystemTrayIcon. hide ( )

隐藏系统托盘条目。

另请参阅

show() visible

PySide2.QtWidgets.QSystemTrayIcon. icon ( )
返回类型

QIcon

另请参阅

setIcon()

static PySide2.QtWidgets.QSystemTrayIcon. isSystemTrayAvailable ( )
返回类型

bool

返回 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 .

PySide2.QtWidgets.QSystemTrayIcon. isVisible ( )
返回类型

bool

PySide2.QtWidgets.QSystemTrayIcon. messageClicked ( )
PySide2.QtWidgets.QSystemTrayIcon. setContextMenu ( menu )
参数

menu QMenu

设置指定 menu 成为用于系统托盘图标的上下文菜单。

菜单会弹出,当用户通过点击鼠标按钮请求用于系统托盘图标的上下文菜单时。

On macOS, this is currenly converted to a NSMenu, so the aboutToHide() signal is not emitted.

注意

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.

另请参阅

contextMenu()

PySide2.QtWidgets.QSystemTrayIcon. setIcon ( icon )
参数

icon QIcon

另请参阅

icon()

PySide2.QtWidgets.QSystemTrayIcon. setToolTip ( tip )
参数

tip – unicode

另请参阅

toolTip()

PySide2.QtWidgets.QSystemTrayIcon. setVisible ( visible )
参数

visible bool

另请参阅

isVisible()

PySide2.QtWidgets.QSystemTrayIcon. show ( )

在系统托盘展示图标。

另请参阅

hide() visible

PySide2.QtWidgets.QSystemTrayIcon. showMessage ( title , msg [ , icon=QSystemTrayIcon.Information [ , msecs=10000 ] ] )
参数
  • title – unicode

  • msg – unicode

  • icon MessageIcon

  • msecs int

PySide2.QtWidgets.QSystemTrayIcon. showMessage ( title , msg , icon [ , msecs=10000 ] )
参数
  • title – unicode

  • msg – unicode

  • icon QIcon

  • msecs int

static PySide2.QtWidgets.QSystemTrayIcon. supportsMessages ( )
返回类型

bool

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

另请参阅

showMessage()

PySide2.QtWidgets.QSystemTrayIcon. toolTip ( )
返回类型

unicode

另请参阅

setToolTip()