QTabletEvent 类

QTabletEvent class contains parameters that describe a Tablet event. 更多...

头: #include <QTabletEvent>
qmake: QT += gui
继承: QInputEvent

公共类型

enum PointerType { UnknownPointer, Pen, Cursor, Eraser }
enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse, RotationStylus }

公共函数

QTabletEvent (Type type , const QPointF & pos , const QPointF & globalPos , int device , int pointerType , qreal pressure , int xTilt , int yTilt , qreal tangentialPressure , qreal rotation , int z , Qt::KeyboardModifiers keyState , qint64 uniqueID , Qt::MouseButton button , Qt::MouseButtons buttons )
Qt::MouseButton button () const
Qt::MouseButtons buttons () const
TabletDevice device () const
QPoint globalPos () const
const QPointF & globalPosF () const
int globalX () const
int globalY () const
(弃用) const QPointF & hiResGlobalPos () const
qreal hiResGlobalX () const
qreal hiResGlobalY () const
PointerType pointerType () const
QPoint pos () const
const QPointF & posF () const
qreal pressure () const
qreal rotation () const
qreal tangentialPressure () const
qint64 uniqueId () const
int x () const
int xTilt () const
int y () const
int yTilt () const
int z () const

额外继承成员

详细描述

QTabletEvent class contains parameters that describe a Tablet event.

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

数位板事件类似于鼠标事件;例如, x (), y (), pos (), globalX (), globalY (),和 globalPos () 访问器提供光标位置,且可以看到哪个 buttons () are pressed (pressing the stylus tip against the tablet surface is equivalent to a left mouse button). But tablet events also pass through some extra information that the tablet device driver provides; for example, you might want to do subpixel rendering with higher resolution coordinates ( hiResGlobalX () 和 hiResGlobalY ()), adjust color brightness based on the pressure () of the tool against the tablet surface, use different brushes depending on the type of tool in use ( device ()), modulate the brush shape in some way according to the X-axis and Y-axis tilt of the tool with respect to the tablet surface ( xTilt () 和 yTilt ()), and use a virtual eraser instead of a brush if the user switches to the other end of a double-ended stylus ( pointerType ()).

Every event contains an accept flag that indicates whether the receiver wants the event. You should call 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 and do not check whether or not they are accepted.

QWidget::setEnabled () 函数可用于启用/禁用 Widget 的鼠标、平板电脑和键盘事件。

事件处理程序 QWidget::tabletEvent () 接收 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.

New in Qt 5.4: QTabletEvent includes all information available from the device, including QTabletEvent::buttons (). Previously it was not possible to accept all tablet events and also know which stylus buttons were pressed.

Note that pressing the stylus button while the stylus hovers over the tablet will generate a button press on some types of tablets, while on other types it will be necessary to press the stylus against the tablet surface in order to register the simultaneous stylus button press.

X11 用户注意事项

If the tablet is configured in xorg.conf to use the Wacom driver, there will be separate XInput "devices" for the stylus, eraser, and (optionally) cursor and touchpad. Qt recognizes these by their names. Otherwise, if the tablet is configured to use the evdev driver, there will be only one device and applications may not be able to distinguish the stylus from the eraser.

Windows 用户注意事项

Tablet support currently requires the WACOM windows driver providing the DLL wintab32.dll to be installed. It is contained in older packages, for example pentablet_5.3.5-3.exe .

成员类型文档编制

enum QTabletEvent:: PointerType

此枚举定义生成事件是什么点类型。

常量 描述
QTabletEvent::UnknownPointer 0 未知设备。
QTabletEvent::Pen 1 像手写笔设备的尖端 (笔的窄端)。
QTabletEvent::Cursor 2 任何像游标的设备。
QTabletEvent::Eraser 3 像手写笔设备的橡皮擦端 (笔的宽端)。

另请参阅 pointerType ().

enum QTabletEvent:: TabletDevice

此枚举定义生成事件的设备类型。

常量 描述
QTabletEvent::NoDevice 0 没有设备,或未知设备。
QTabletEvent::Puck 1 游标 (类似扁平鼠标的设备,带有十字准线透明圆圈)。
QTabletEvent::Stylus 2 手写笔。
QTabletEvent::Airbrush 3 喷枪
QTabletEvent::FourDMouse 4 4D 鼠标。
QTabletEvent::RotationStylus 6 特殊手写笔,还知道旋转 (6D 手写笔)。

该枚举在 Qt 4.1 引入或被修改。

成员函数文档编制

QTabletEvent:: QTabletEvent ( Type type , const QPointF & pos , const QPointF & globalPos , int device , int pointerType , qreal pressure , int xTilt , int yTilt , qreal tangentialPressure , qreal rotation , int z , Qt::KeyboardModifiers keyState , qint64 uniqueID , Qt::MouseButton button , Qt::MouseButtons buttons )

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

pos 参数指示事件发生在 Widget 中哪里; globalPos is the corresponding position in absolute coordinates.

pressure contains the pressure exerted on the device .

pointerType 描述正在使用的笔类型。

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

keyState specifies which keyboard modifiers are pressed (e.g., Ctrl ).

uniqueID parameter contains the unique ID for the current device.

z parameter contains the coordinate of the device on the tablet, this is usually given by a wheel on 4D mouse. If the device does not support a Z-axis, pass zero here.

tangentialPressure parameter contins the tangential pressure of an air brush. If the device does not support tangential pressure, pass 0 here.

rotation contains the device's rotation in degrees. 4D mice and the Wacom Art Pen support rotation. If the device does not support rotation, pass 0 here.

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

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

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

Qt::MouseButton QTabletEvent:: button () const

返回导致事件的按钮。

注意:返回值始终是 Qt::NoButton for TabletMove , TabletEnterProximity and TabletLeaveProximity 事件。

另请参阅 buttons () 和 Qt::MouseButton .

Qt::MouseButtons QTabletEvent:: buttons () const

Returns the button state when the event was generated. The button state is a combination of buttons from the Qt::MouseButton enum using the OR operator. For TabletMove events, this is all buttons that are pressed down. For TabletPress events this includes the button that caused the event. For TabletRelease events this excludes the button that caused the event.

另请参阅 button () 和 Qt::MouseButton .

TabletDevice QTabletEvent:: device () const

返回生成事件的设备类型。

另请参阅 TabletDevice .

QPoint QTabletEvent:: globalPos () const

Returns the global position of the device 在事件发生时 . This is important on asynchronous windows systems like X11; whenever you move your widgets around in response to mouse events, globalPos() can differ significantly from the current position QCursor::pos ().

另请参阅 globalX (), globalY (),和 hiResGlobalPos ().

const QPointF &QTabletEvent:: globalPosF () const

Returns the global position of the device 在事件发生时 . This is important on asynchronous windows systems like X11; whenever you move your widgets around in response to mouse events, globalPosF() can differ significantly from the current position QCursor::pos ().

另请参阅 posF ().

int QTabletEvent:: globalX () const

返回事件发生时鼠标指针的全局 x 位置。

另请参阅 globalY (), globalPos (),和 hiResGlobalX ().

int QTabletEvent:: globalY () const

返回事件发生时数位板设备的全局 y 位置。

另请参阅 globalX (), globalPos (),和 hiResGlobalY ().

const QPointF &QTabletEvent:: hiResGlobalPos () const

此函数被弃用。

The high precision coordinates delivered from the tablet expressed. Sub pixeling information is in the fractional part of the QPointF .

另请参阅 globalPos (), hiResGlobalX (),和 hiResGlobalY ().

qreal QTabletEvent:: hiResGlobalX () const

The high precision x position of the tablet device.

qreal QTabletEvent:: hiResGlobalY () const

The high precision y position of the tablet device.

PointerType QTabletEvent:: pointerType () const

返回生成事件的点类型。

QPoint QTabletEvent:: pos () const

返回设备位置,相对接收事件 Widget。

若为响应鼠标事件而移动 Widget,使用 globalPos () 而不是此函数。

另请参阅 x (), y (),和 globalPos ().

const QPointF &QTabletEvent:: posF () const

返回设备位置,相对接收事件 Widget。

若为响应鼠标事件而移动 Widget,使用 globalPosF () 而不是此函数。

另请参阅 globalPosF ().

qreal QTabletEvent:: pressure () const

Returns the pressure for the device. 0.0 indicates that the stylus is not on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.

另请参阅 tangentialPressure ().

qreal QTabletEvent:: rotation () const

Returns the rotation of the current device in degress. This is usually given by a 4D Mouse. If the device does not support rotation this value is always 0.0.

qreal QTabletEvent:: tangentialPressure () const

Returns the tangential pressure for the device. This is typically given by a finger wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a neutral position. Current airbrushes can only move in the positive direction from the neutrual position. If the device does not support tangential pressure, this value is always 0.0.

另请参阅 pressure ().

qint64 QTabletEvent:: uniqueId () const

Returns a unique ID for the current device, making it possible to differentiate between multiple devices being used at the same time on the tablet.

此特征的支持从属数位板。

同一设备的值可能因操作系统而异。

Later versions of the Wacom driver for Linux will now report the ID information. If you have a tablet that supports unique ID and are not getting the information on Linux, consider upgrading your driver.

As of Qt 4.2, the unique ID is the same regardless of the orientation of the pen. Earlier versions would report a different value when using the eraser-end versus the pen-end of the stylus on some OS's.

另请参阅 pointerType ().

int QTabletEvent:: x () const

返回设备的 x 位置,相对接收事件 Widget。

另请参阅 y () 和 pos ().

int QTabletEvent:: xTilt () const

Returns the angle between the device (a pen, for example) and the perpendicular in the direction of the x axis. Positive values are towards the tablet's physical right. The angle is in the range -60 to +60 degrees.

另请参阅 yTilt ().

int QTabletEvent:: y () const

返回设备的 y 位置,相对接收事件 Widget。

另请参阅 x () 和 pos ().

int QTabletEvent:: yTilt () const

Returns the angle between the device (a pen, for example) and the perpendicular in the direction of the y axis. Positive values are towards the bottom of the tablet. The angle is within the range -60 to +60 degrees.

另请参阅 xTilt ().

int QTabletEvent:: z () const

Returns the z position of the device. Typically this is represented by a wheel on a 4D Mouse. If the device does not support a Z-axis, this value is always zero. This is not the same as pressure.

另请参阅 pressure ().