PySide6.QtGui.QPointingDevice

class QPointingDevice

QPointingDevice 类描述了产生鼠标、触摸或平板事件的设备。更多

PySide6.QtGui.QPointingDevice 的继承图

概要

属性

方法

信号

静态函数

注意

本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。

详细描述

每个QPointerEvent包含一个QPointingDevice指针,以允许访问设备特定的属性,如类型和功能。平台或通用插件有责任在生成任何指针事件之前通过QWindowSystemInterface注册可用的指向设备。应用程序不需要实例化这个类,它们应该只访问由device()指向的全局实例。

class PointerType

(继承自 enum.Flag) 此枚举表示与指向设备交互的内容。

此属性与DeviceType之间存在一些冗余。例如,如果使用触摸屏,则DeviceTypeTouchScreen,而PointerType始终为Finger。但在图形输入板上,通常可以使用触控笔的两端,程序需要区分它们。因此,这个概念被扩展,使得每个QPointerEvent都有一个PointerType,并且它可以简化一些事件处理代码,忽略DeviceType并根据PointerType做出不同的反应。

有效值为:

常量

描述

QPointingDevice.PointerType.Unknown

指针类型未知。

QPointingDevice.PointerType.Generic

鼠标或类似鼠标的设备(X11上的核心指针)。

QPointingDevice.PointerType.Finger

用户的手指。

QPointingDevice.PointerType.Pen

触控笔的绘图端。

QPointingDevice.PointerType.Eraser

触控笔的另一端(如果另一端有虚拟橡皮擦)。

QPointingDevice.PointerType.Cursor

一个透明的圆圈,带有十字准线,类似于Puck设备上的样式。

QPointingDevice.PointerType.AllPointerTypes

以上任意一种(用作默认过滤值)。

class GrabTransition

此枚举表示独占或被动抓取从一个对象(可能是nullptr)到另一个对象(可能是nullptr)的转换。它作为grabChanged()信号的参数发出。

有效值为:

常量

描述

QPointingDevice.GrabExclusive

setExclusiveGrabber()之后发出。

QPointingDevice.UngrabExclusive

setExclusiveGrabber()之后发出,当抓取器设置为nullptr时,通知抓取已正常终止。

QPointingDevice.CancelGrabExclusive

setExclusiveGrabber()之后发出,当抓取器被设置为不同的对象时,通知旧的抓取器的抓取被“窃取”。

QPointingDevice.GrabPassive

addPassiveGrabber()之后发出。

QPointingDevice.UngrabPassive

当被动抓取正常终止时发出,例如在removePassiveGrabber()之后。

QPointingDevice.CancelGrabPassive

当被动抓取异常终止时发出(手势被取消)。

QPointingDevice.OverrideGrabPassive

此值当前未使用。

注意

当使用from __feature__ import true_property时,属性可以直接使用,否则通过访问器函数使用。

property buttonCountᅟ: int
Access functions:
property maximumPointsᅟ: int
Access functions:
property pointerTypeᅟ: QPointingDevice.PointerType
Access functions:
property uniqueIdᅟ: QPointingDeviceUniqueId
Access functions:
__init__([parent=None])
Parameters:

父对象QObject

创建一个新的无效指向设备实例作为parent的子项。

__init__(name, systemId, devType, pType, caps, maxPoints, buttonCount[, seatName=""[, uniqueId=QPointingDeviceUniqueId()[, parent=None]]])
Parameters:

使用给定的namedeviceTypepointerTypecapabilitiesmaxPointsbuttonCountseatNameuniqueIdparent创建一个新的指向设备实例。

buttonCount()
Return type:

整数

返回可以检测到的设备上按钮的最大数量。

属性 buttonCountᅟ 的获取器。

grabChanged(grabber, transition, event, point)
Parameters:

grabber对象在传递event期间获得或失去对point的独占或被动抓取时,会发出此信号。transitiongrabber对象的角度说明了发生了什么。

注意

从一个对象到另一个对象的抓取过渡会产生两个信号,以通知一个对象已经失去了抓取,并通知有另一个抓取者。在其他情况下,当过渡到或从非抓取状态时,只发出一个信号:grabber参数永远不会是nullptr

maximumPoints()
Return type:

整数

返回可以检测到的同时触摸点(手指)的最大数量。

属性 maximumPointsᅟ 的获取器。

__eq__(other)
Parameters:

其他QPointingDevice

Return type:

布尔

pointerType()
Return type:

PointerType

返回指针类型。

属性 pointerTypeᅟ 的获取器。

static primaryPointingDevice([seatName=""])
Parameters:

seatName – str

Return type:

QPointingDevice

返回给定座位 seatName 上的主要指向设备(核心指针,传统上假设为鼠标)。

如果注册了多个指向设备,此函数优先选择与给定seatName匹配且没有其他设备作为其父设备的鼠标或触摸板。通常只有一个主设备或核心设备没有父设备。但如果未找到此类设备,此函数将创建一个新的虚拟“核心指针”鼠标。因此,Qt 可以在尚未进行输入设备发现和注册的平台上继续工作。

setCapabilities(caps)
Parameters:

capsCapability 的组合

注意

此函数已弃用。

请使用构造函数而不是setter方法。

setMaximumTouchPoints(c)
Parameters:

c – 整数

注意

此函数已弃用。

请使用构造函数而不是setter方法。

setType(devType)
Parameters:

devTypeDeviceType

注意

此函数已弃用。

请使用构造函数而不是setter方法。

设置设备类型 devType 并推断指针类型。

uniqueId()
Return type:

QPointingDeviceUniqueId

返回设备的唯一ID(实用性存疑)。

你可能更应该关注QPointerEventPoint::uniqueId()。

属性 uniqueIdᅟ 的获取器。