QTabletEvent¶
The
QTabletEvent
class contains parameters that describe a Tablet event. More…
Synopsis¶
Functions¶
def
button
()def
buttons
()def
device
()def
deviceType
()def
globalPos
()def
globalPosF
()def
globalX
()def
globalY
()def
hiResGlobalX
()def
hiResGlobalY
()def
pointerType
()def
pos
()def
posF
()def
pressure
()def
rotation
()def
tangentialPressure
()def
uniqueId
()def
x
()def
xTilt
()def
y
()def
yTilt
()def
z
()
Detailed Description¶
Tablet events are generated from tablet peripherals such as Wacom tablets and various other brands, and electromagnetic stylus devices included with some types of tablet computers. (It is not the same as
QTouchEvent
which a touchscreen generates, even when a passive stylus is used on a touchscreen.)Tablet events are similar to mouse events; for example, the
x()
,y()
,pos()
,globalX()
,globalY()
, andglobalPos()
accessors provide the cursor position, and you can see whichbuttons()
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 (globalPosF()
), adjust color brightness based on thepressure()
of the tool against the tablet surface, use different brushes depending on the type of tool in use (deviceType()
), 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()
andyTilt()
), 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
accept()
if you handle the tablet event; otherwise it will be sent to the parent widget. The exception areTabletEnterProximity
andTabletLeaveProximity
events: these are only sent toQApplication
and do not check whether or not they are accepted.The
setEnabled()
function can be used to enable or disable mouse, tablet and keyboard events for a widget.The event handler
tabletEvent()
receivesTabletPress
,TabletRelease
andTabletMove
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, includingbuttons()
. 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.
Notes for X11 Users¶
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.
Notes for Windows Users¶
Tablet support currently requires the WACOM windows driver providing the DLL
wintab32.dll
to be installed. It is contained in older packages, for examplepentablet_5.3.5-3.exe
.
- class PySide2.QtGui.QTabletEvent(t, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, uniqueID)¶
Note
This constructor is deprecated.
PySide2.QtGui.QTabletEvent(t, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, uniqueID, button, buttons)
- param globalPos:
- param rotation:
float
- param z:
int
- param uniqueID:
int
- param pointerType:
int
- param buttons:
MouseButtons
- param pos:
- param device:
int
- param yTilt:
int
- param xTilt:
int
- param button:
- param keyState:
KeyboardModifiers
- param t:
- param pressure:
float
- param tangentialPressure:
float
Construct a tablet event of the given
type
.The
pos
parameter indicates where the event occurred in the widget;globalPos
is the corresponding position in absolute coordinates.pressure
contains the pressure exerted on thedevice
.pointerType
describes the type of pen that is being used.xTilt
andyTilt
contain the device’s degree of tilt from the x and y axes respectively.keyState
specifies which keyboard modifiers are pressed (e.g., Ctrl).The
uniqueID
parameter contains the unique ID for the current device.The
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.The
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 support rotation. If the device does not support rotation, pass 0 here.in 5.4: use the constructor with MouseButton status
See also
pos()
globalPos()
device()
pressure()
xTilt()
yTilt()
uniqueId()
rotation()
tangentialPressure()
z()
Construct a tablet event of the given
type
.The
pos
parameter indicates where the event occurred in the widget;globalPos
is the corresponding position in absolute coordinates.pressure
contains the pressure exerted on thedevice
.pointerType
describes the type of pen that is being used.xTilt
andyTilt
contain the device’s degree of tilt from the x and y axes respectively.keyState
specifies which keyboard modifiers are pressed (e.g., Ctrl).The
uniqueID
parameter contains the unique ID for the current device.The
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.The
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, the Wacom Art Pen, and the Apple Pencil support rotation. If the device does not support rotation, pass 0 here.The
button
that caused the event is given as a value from theMouseButton
enum. If the eventtype
is notTabletPress
orTabletRelease
, the appropriate button for this event isNoButton
.buttons
is the state of all buttons at the time of the event.
- PySide2.QtGui.QTabletEvent.TabletDevice¶
This enum defines what type of device is generating the event.
Constant
Description
QTabletEvent.NoDevice
No device, or an unknown device.
QTabletEvent.Puck
A Puck (a device that is similar to a flat mouse with a transparent circle with cross-hairs).
QTabletEvent.Stylus
A Stylus.
QTabletEvent.Airbrush
An airbrush
QTabletEvent.FourDMouse
A 4D Mouse.
QTabletEvent.RotationStylus
A special stylus that also knows about rotation (a 6D stylus).
- PySide2.QtGui.QTabletEvent.PointerType¶
This enum defines what type of point is generating the event.
Constant
Description
QTabletEvent.UnknownPointer
An unknown device.
QTabletEvent.Pen
Tip end of a stylus-like device (the narrow end of the pen).
QTabletEvent.Cursor
Any puck-like device.
QTabletEvent.Eraser
Eraser end of a stylus-like device (the broad end of the pen).
See also
- PySide2.QtGui.QTabletEvent.button()¶
- Return type:
Returns the button that caused the event.
Note that the returned value is always
NoButton
forTabletMove
,TabletEnterProximity
andTabletLeaveProximity
events.See also
buttons()
MouseButton
- PySide2.QtGui.QTabletEvent.buttons()¶
- Return type:
MouseButtons
Returns the button state when the event was generated. The button state is a combination of buttons from the
MouseButton
enum using the OR operator. ForTabletMove
events, this is all buttons that are pressed down. ForTabletPress
events this includes the button that caused the event. ForTabletRelease
events this excludes the button that caused the event.See also
button()
MouseButton
- PySide2.QtGui.QTabletEvent.device()¶
- Return type:
Note
This function is deprecated.
Use
deviceType()
.
- PySide2.QtGui.QTabletEvent.deviceType()¶
- Return type:
Returns the type of device that generated the event.
See also
TabletDevice
- PySide2.QtGui.QTabletEvent.globalPos()¶
- Return type:
Returns the global position of the device at the time of the event . This is important on asynchronous windows systems like X11; whenever you move your widgets around in response to mouse events, can differ significantly from the current position
pos()
.
- PySide2.QtGui.QTabletEvent.globalPosF()¶
- Return type:
Returns the global position of the device at the time of the event . This is important on asynchronous windows systems like X11; whenever you move your widgets around in response to mouse events, can differ significantly from the current position
pos()
.See also
- PySide2.QtGui.QTabletEvent.globalX()¶
- Return type:
int
Returns the global x position of the mouse pointer at the time of the event.
See also
- PySide2.QtGui.QTabletEvent.globalY()¶
- Return type:
int
Returns the global y position of the tablet device at the time of the event.
See also
- PySide2.QtGui.QTabletEvent.hiResGlobalX()¶
- Return type:
float
Note
This function is deprecated.
The high precision x position of the tablet device.
use
globalPosF()
- PySide2.QtGui.QTabletEvent.hiResGlobalY()¶
- Return type:
float
Note
This function is deprecated.
The high precision y position of the tablet device.
use
globalPosF()
- PySide2.QtGui.QTabletEvent.pointerType()¶
- Return type:
Returns the type of point that generated the event.
- PySide2.QtGui.QTabletEvent.pos()¶
- Return type:
Returns the position of the device, relative to the widget that received the event.
If you move widgets around in response to mouse events, use
globalPos()
instead of this function.See also
- PySide2.QtGui.QTabletEvent.posF()¶
- Return type:
Returns the position of the device, relative to the widget that received the event.
If you move widgets around in response to mouse events, use
globalPosF()
instead of this function.See also
- PySide2.QtGui.QTabletEvent.pressure()¶
- Return type:
float
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.
See also
- PySide2.QtGui.QTabletEvent.rotation()¶
- Return type:
float
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.
- PySide2.QtGui.QTabletEvent.tangentialPressure()¶
- Return type:
float
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.
See also
- PySide2.QtGui.QTabletEvent.uniqueId()¶
- Return type:
int
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.
Support of this feature is dependent on the tablet.
Values for the same device may vary from OS to OS.
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.
See also
- PySide2.QtGui.QTabletEvent.x()¶
- Return type:
int
Returns the x position of the device, relative to the widget that received the event.
- PySide2.QtGui.QTabletEvent.xTilt()¶
- Return type:
int
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.
See also
- PySide2.QtGui.QTabletEvent.y()¶
- Return type:
int
Returns the y position of the device, relative to the widget that received the event.
- PySide2.QtGui.QTabletEvent.yTilt()¶
- Return type:
int
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.
See also
- PySide2.QtGui.QTabletEvent.z()¶
- Return type:
int
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.
See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.