QTabletEvent 类

QTabletEvent 类包含数位板事件的描述参数。 更多...

头: #include <QTabletEvent>
CMake: find_package(Qt6 COMPONENTS Gui REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承: QSinglePointEvent

公共函数

  QTabletEvent (QEvent::Type type , const QPointingDevice * dev , const QPointF & pos , const QPointF & globalPos , qreal pressure , float xTilt , float yTilt , float tangentialPressure , qreal rotation , float z , Qt::KeyboardModifiers keyState , Qt::MouseButton button , Qt::MouseButtons buttons )
qreal pressure () const
qreal rotation () const
qreal tangentialPressure () const
qreal xTilt () const
qreal yTilt () const
qreal z () const

详细描述

数位板事件 由数位板外围设备 (譬如 Wacom 数位板及各种其它品牌) 和电磁手写笔设备 (包括采用某些类型的数位板计算机) 生成。(不同于 QTouchEvent 触摸屏生成,甚至在触摸屏上使用无源手写笔时)。

数位板事件类似于鼠标事件;例如, x (), y (), pos (), globalX (), globalY (),和 globalPos () 访问器提供光标位置,且可以看到哪个 buttons () 被按下 (将手写笔尖端按在数位板表面相当于鼠标左键)。但数位板事件还传递数位板设备驱动程序提供的一些额外信息;例如,可能想要做更高分辨率坐标的亚像素渲染 ( globalPosF ()),调节颜色亮度基于 pressure () 将工具紧靠数位板表面,使用不同笔刷根据使用中的工具类型 ( deviceType ()),以某种方式调节笔刷形状根据工具相对数位板表面 X 轴和 Y 轴的倾斜 ( xTilt () 和 yTilt ()),及使用虚拟橡皮擦而不是笔刷若用户切换到双端手写笔的另一端 ( pointerType ()).

每个事件均包含接受标志,指示接收者是否想要此事件。应该调用 QTabletEvent::accept () if you handle the tablet event; otherwise it will be sent to the parent widget. The exception are TabletEnterProximity and TabletLeaveProximity events: these are only sent to QApplication 且不校验它们是否被接受。

QWidget::setEnabled () 函数可以用于启用/禁用 Widget 的鼠标、数位板及键盘事件。

事件处理程序 QWidget::tabletEvent () receives TabletPress, TabletRelease and TabletMove events. Qt will first send a tablet event, then if it is not accepted by any widget, it will send a mouse event. This allows users of applications that are not designed for tablets to use a tablet like a mouse. However high-resolution drawing applications should handle the tablet events, because they can occur at a higher frequency, which is a benefit for smooth and accurate drawing. If the tablet events are rejected, the synthetic mouse events may be compressed for efficiency.

注意,当按下悬停在数位板上的手写笔按钮时将生成某些类型的数位板按钮按下,而对于其它类型,将手写笔按在数位板表面以同时注册按下手写笔按钮有必要。

X11 用户注意事项

若数位板在 xorg.conf 被配置为使用 Wacom 驱动程序,则手写笔、橡皮擦及 (可选) 光标和触摸板将存在单独 XInput "设备"。Qt 通过它们的名称识别这些。否则,若数位板被配置为使用 evdev 驱动程序,将只存在一个设备且应用程序可能无法区分手写笔和橡皮擦。

Windows 用户注意事项

数位板支持目前要求 WACOM Windows 驱动程序提供 DLL wintab32.dll 待安装。它包含在较旧包中,例如 pentablet_5.3.5-3.exe .

成员函数文档编制

QTabletEvent:: QTabletEvent ( QEvent::Type type , const QPointingDevice * dev , const QPointF & pos , const QPointF & globalPos , qreal pressure , float xTilt , float yTilt , float tangentialPressure , qreal rotation , float z , Qt::KeyboardModifiers keyState , Qt::MouseButton button , Qt::MouseButtons buttons )

构造数位板事件为给定 type .

pos 参数指示事件发生在 Widget 中哪里; globalPos 是绝对坐标对应位置。

pressure gives the pressure exerted on the device dev .

xTilt and yTilt give the device's degree of tilt from the x and y axes respectively.

keyState 指定按下了哪个键盘修饰符 (如 Ctrl ).

z parameter gives the Z coordinate of the device on the tablet; this is usually given by a wheel on a 4D mouse. If the device does not support a Z-axis (i.e. QPointingDevice::capabilities () does not include ZPosition ), pass 0 这里。

tangentialPressure parameter gives the tangential pressure thumbwheel value from an airbrush. If the device does not support tangential pressure (i.e. QPointingDevice::capabilities () does not include TangentialPressure ), pass 0 这里。

rotation gives the device's rotation in degrees. 4D mice, the Wacom Art Pen, and the Apple Pencil support rotation. If the device does not support rotation (i.e. QPointingDevice::capabilities () does not include Rotation ), pass 0 这里。

button 导致给定值事件来自 Qt::MouseButton 枚举。若事件 type 不是 TabletPress or TabletRelease ,此事件的相应按钮为 Qt::NoButton .

buttons 是事件发生时的所有按钮状态。

另请参阅 pos (), globalPos (), device (), pressure (), xTilt (), yTilt (), uniqueId (), rotation (), tangentialPressure (),和 z ().

qreal QTabletEvent:: pressure () const

返回设备的压力。0.0 指示手写笔不在数位板中,1.0 指示手写笔的最大压力数。

另请参阅 tangentialPressure ().

qreal QTabletEvent:: rotation () const

Returns the rotation of the current tool in degrees, where zero means the tip of the stylus is pointing towards the top of the tablet, a positive value means it's turned to the right, and a negative value means it's turned to the left. This can be given by a 4D Mouse or a rotation-capable stylus (such as the Wacom Art Pen or the Apple Pencil). If the device does not support rotation, this value is always 0.0.

qreal QTabletEvent:: tangentialPressure () const

返回设备的切向压力。这通常由喷枪工具指轮给出。范围是从 -1.0 到 1.0。0.0 指示中立位置。目前喷枪只可以从中立位置向正值方向移动。若设备不支持切向压力,此值始终为 0.0。

注意: 值按单精度浮点形式存储。

另请参阅 pressure ().

qreal QTabletEvent:: xTilt () const

返回设备 (例如:钢笔) 和 X 轴垂直方向之间的角度。正值朝向数位板物理右侧。角度范围 -60 到 +60 度。

注意: 值按单精度浮点形式存储。

另请参阅 yTilt ().

qreal QTabletEvent:: yTilt () const

返回设备 (例如:钢笔) 和 Y 轴垂直方向之间的角度。正值朝向数位板底部。角度范围 -60 到 +60 度。

注意: 值按单精度浮点形式存储。

另请参阅 xTilt ().

qreal QTabletEvent:: z () const

返回设备的 Z 位置。通常,这由 4D 鼠标滚轮表示。若设备不支持 Z 轴,此值始终为 0。这是 not 如同压力。

注意: 值按单精度浮点形式存储。

另请参阅 pressure ().