- class QInputDevice#
The
QInputDevice
class describes a device from which aQInputEvent
originates. More…Inherited by:
QPointingDevice
Synopsis#
Properties#
Methods#
def
__init__()
def
capabilities()
def
hasCapability()
def
name()
def
__eq__()
def
seatName()
def
systemId()
def
type()
Signals#
Static functions#
def
devices()
def
seatNames()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
Each
QInputEvent
contains aQInputDevice
pointer to allow accessing device-specific properties like type, capabilities and seat. It is the responsibility of the platform or generic plug-ins to discover, create and register an instance of this class corresponding to each available input device, via QWindowSystemInterface::registerInputDevice(), before generating any input event referring to that device.Applications do not need to instantiate this class, but can read the instances pointed to by
device()
anddevices()
.- class DeviceType#
(inherits
enum.Flag
) This enum represents the type of device that generated aQPointerEvent
.Constant
Description
QInputDevice.DeviceType.Unknown
The device cannot be identified.
QInputDevice.DeviceType.Mouse
A mouse.
QInputDevice.DeviceType.TouchScreen
In this type of device, the touch surface and display are integrated. This means the surface and display typically have the same size, such that there is a direct relationship between the touch points’ physical positions and the coordinate reported by
QEventPoint
. As a result, Qt allows the user to interact directly with multiple QWidgets, QGraphicsItems, or Qt Quick Items at the same time.QInputDevice.DeviceType.TouchPad
In this type of device, the touch surface is separate from the display. There is not a direct relationship between the physical touch location and the on-screen coordinates. Instead, they are calculated relative to the current mouse position, and the user must use the touch-pad to move this reference point. Unlike touch-screens, Qt allows users to only interact with a single QWidget or QGraphicsItem at a time.
QInputDevice.DeviceType.Stylus
A pen-like device used on a graphics tablet such as a Wacom tablet, or on a touchscreen that provides a separate stylus sensing capability.
QInputDevice.DeviceType.Airbrush
A stylus with a thumbwheel to adjust
tangentialPressure
.QInputDevice.DeviceType.Puck
A device that is similar to a flat mouse with a transparent circle with cross-hairs.
QInputDevice.DeviceType.Keyboard
A keyboard.
QInputDevice.DeviceType.AllDevices
Any of the above (used as a default filter value).
- class Capability#
(inherits
enum.Flag
) Indicates what kind of information the input device or its driver can provide.Constant
Description
QInputDevice.Capability.None
No information about input device capabilities available.
QInputDevice.Capability.Position
Indicates that position information is available, meaning that the position() family of functions in the touch points return valid points.
QInputDevice.Capability.Area
Indicates that touch area information is available, meaning that
ellipseDiameters()
in the touch points return valid values.QInputDevice.Capability.Pressure
Indicates that pressure information is available, meaning that
pressure()
returns a valid value.QInputDevice.Capability.Velocity
Indicates that velocity information is available, meaning that
velocity()
returns a valid vector.QInputDevice.Capability.NormalizedPosition
Indicates that the normalized position is available, meaning that
globalPosition()
returns a valid value.QInputDevice.Capability.MouseEmulation
Indicates that the device synthesizes mouse events.
QInputDevice.Capability.Scroll
Indicates that the device has a scroll capability.
QInputDevice.Capability.PixelScroll
Indicates that the device (usually a
touchpad
) scrolls withpixel precision
.QInputDevice.Capability.Hover
Indicates that the device has a hover capability.
QInputDevice.Capability.Rotation
Indicates that
rotation
information is available.QInputDevice.Capability.XTilt
Indicates that
tilt
information is available for the X-axis.QInputDevice.Capability.YTilt
Indicates that
tilt
information is available for the Y-axis.QInputDevice.Capability.TangentialPressure
Indicates that
tangential pressure
information is available.QInputDevice.Capability.ZPosition
Indicates that position information for the
Z-axis
is available.QInputDevice.Capability.All
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- Access functions:
- property capabilitiesᅟ: Combination of QDBusConnection.ConnectionCapability#
- Access functions:
- property nameᅟ: str#
- Access functions:
- property seatNameᅟ: str#
- Access functions:
- property systemIdᅟ: int#
- Access functions:
- property typeᅟ: QInputDevice.DeviceType#
- Access functions:
Creates a new invalid input device instance as a child of
parent
.- __init__(name, systemId, type[, seatName=""[, parent=None]])
- Parameters:
name – str
systemId – int
type –
DeviceType
seatName – str
parent –
QObject
Creates a new input device instance. The given
name
is normally a manufacturer-assigned model name if available, or something else identifiable;id
is a platform-specific number that will be unique per device (for example the xinput ID on X11);type
identifies what kind of device. On window systems that are capable of handling input from multiple users or sets of input devices at the same time (such as Wayland or X11),seatName
identifies the name of the set of devices that will be used together. If the device is a child or slave device (for example one of several mice that can take turns moving the “core pointer”), the master device should be given as theparent
.The platform plugin creates, registers and continues to own each device instance; usually
parent
should be given for memory management purposes even if there is no master for a particular device.By default,
capabilities()
areNone
.Returns the region within the
virtual desktop
that this device can access.For example a
TouchScreen
input device is fixed in place upon a single physical screen, and usually calibrated so that this area is the same asgeometry()
; whereas aMouse
can probably access all screens on the virtual desktop. A Wacom graphics tablet may be configured in a way that it’s mapped to all screens, or only to the screen where the user prefers to create drawings, or to the window in which drawing occurs. AStylus
device that is integrated with a touchscreen may be physically limited to that screen.If the returned rectangle is null, it means this device can access the entire virtual desktop.
Getter of property
availableVirtualGeometryᅟ
.Notification signal of property
availableVirtualGeometryᅟ
.- capabilities()#
- Return type:
Combination of
Capability
Returns the device capabilities.
- static devices()#
- Return type:
.list of const QInputDevice
Returns a list of all registered input devices (keyboards and pointing devices).
Note
The list of devices is not always complete on all platforms. So far, the most-complete information is available on the X11 platform, at startup and in response to hot-plugging. Most other platforms are only able to provide generic devices of various types, only after receiving events from them; and most platforms do not tell Qt when a device is plugged in, or when it is unplugged at runtime.
Note
The returned list cannot be used to add new devices. To add a simulated touch screen for an autotest, QTest::createTouchDevice() can be used. Platform plugins should call QWindowSystemInterface::registerInputDevice() to add devices as they are discovered.
- hasCapability(cap)#
- Parameters:
cap –
Capability
- Return type:
bool
Returns whether the device capabilities include the given
capability
.- name()#
- Return type:
str
Returns the device name.
This string may be empty. It is however useful on systems that have multiple input devices: it can be used to differentiate from which device a
QPointerEvent
originates.Getter of property
nameᅟ
.- __eq__(other)#
- Parameters:
other –
QInputDevice
- Return type:
bool
- static primaryKeyboard([seatName=""])#
- Parameters:
seatName – str
- Return type:
Returns the core or master keyboard on the given seat
seatName
.- seatName()#
- Return type:
str
Returns the seat with which the device is associated, if known; otherwise empty.
Devices that are intended to be used together by one user may be configured to have the same seat name. That is only possible on Wayland and X11 platforms so far.
Getter of property
seatNameᅟ
.- static seatNames()#
- Return type:
list of strings
Returns a list of seat names for all registered input devices (keyboards and pointing devices).
- systemId()#
- Return type:
int
Returns the platform specific system ID (for example xinput ID on the X11 platform).
All platforms are expected to provide a unique system ID for each device.
Getter of property
systemIdᅟ
.- type()#
- Return type:
Returns the device type.
Getter of property
typeᅟ
.