PySide6.QtGui.QPointingDevice¶
- class QPointingDevice¶
QPointingDevice类描述了产生鼠标、触摸或平板事件的设备。更多…概要¶
属性¶
方法¶
def
__init__()def
buttonCount()def
maximumPoints()def
__eq__()def
pointerType()def
setType()def
uniqueId()
信号¶
def
grabChanged()
静态函数¶
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
每个
QPointerEvent包含一个QPointingDevice指针,以允许访问设备特定的属性,如类型和功能。平台或通用插件有责任在生成任何指针事件之前通过QWindowSystemInterface注册可用的指向设备。应用程序不需要实例化这个类,它们应该只访问由device()指向的全局实例。- class PointerType¶
(继承自
enum.Flag) 此枚举表示与指向设备交互的内容。此属性与
DeviceType之间存在一些冗余。例如,如果使用触摸屏,则DeviceType为TouchScreen,而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:
创建一个新的无效指向设备实例作为
parent的子项。- __init__(name, systemId, devType, pType, caps, maxPoints, buttonCount[, seatName=""[, uniqueId=QPointingDeviceUniqueId()[, parent=None]]])
- Parameters:
name – str
systemId – int
devType –
DeviceTypepType –
PointerTypecaps –
Capability的组合maxPoints – int
buttonCount – int
seatName – str
uniqueId –
QPointingDeviceUniqueIdparent –
QObject
使用给定的
name、deviceType、pointerType、capabilities、maxPoints、buttonCount、seatName、uniqueId和parent创建一个新的指向设备实例。- buttonCount()¶
- Return type:
整数
返回可以检测到的设备上按钮的最大数量。
属性
buttonCountᅟ的获取器。- grabChanged(grabber, transition, event, point)¶
- Parameters:
grabber –
QObjecttransition –
GrabTransition事件 –
QPointerEventpoint –
QEventPoint
当
grabber对象在传递event期间获得或失去对point的独占或被动抓取时,会发出此信号。transition从grabber对象的角度说明了发生了什么。注意
从一个对象到另一个对象的抓取过渡会产生两个信号,以通知一个对象已经失去了抓取,并通知有另一个抓取者。在其他情况下,当过渡到或从非抓取状态时,只发出一个信号:
grabber参数永远不会是nullptr。- maximumPoints()¶
- Return type:
整数
返回可以检测到的同时触摸点(手指)的最大数量。
属性
maximumPointsᅟ的获取器。- __eq__(other)¶
- Parameters:
其他 –
QPointingDevice- Return type:
布尔
- pointerType()¶
- Return type:
返回指针类型。
属性
pointerTypeᅟ的获取器。- static primaryPointingDevice([seatName=""])¶
- Parameters:
seatName – str
- Return type:
返回给定座位
seatName上的主要指向设备(核心指针,传统上假设为鼠标)。如果注册了多个指向设备,此函数优先选择与给定
seatName匹配且没有其他设备作为其父设备的鼠标或触摸板。通常只有一个主设备或核心设备没有父设备。但如果未找到此类设备,此函数将创建一个新的虚拟“核心指针”鼠标。因此,Qt 可以在尚未进行输入设备发现和注册的平台上继续工作。- setCapabilities(caps)¶
- Parameters:
caps –
Capability的组合
注意
此函数已弃用。
请使用构造函数而不是setter方法。
- setMaximumTouchPoints(c)¶
- Parameters:
c – 整数
注意
此函数已弃用。
请使用构造函数而不是setter方法。
- setType(devType)¶
- Parameters:
devType –
DeviceType
注意
此函数已弃用。
请使用构造函数而不是setter方法。
设置设备类型
devType并推断指针类型。- uniqueId()¶
- Return type:
返回设备的唯一ID(实用性存疑)。
你可能更应该关注QPointerEventPoint::uniqueId()。
属性
uniqueIdᅟ的获取器。