返回介绍

QTabletEvent Class

发布于 2019-10-04 15:03:14 字数 8178 浏览 998 评论 0 收藏 0

The QTabletEvent class contains parameters that describe a Tablet event. More...

#include <qevent.h>

Inherits QEvent.

List of all member functions.

Public Members

  • enum TabletDevice { NoDevice = -1, Puck, Stylus, Eraser }
  • QTabletEvent ( constQPoint&pos, intdevice, intpressure, intxTilt, intyTilt, constQPair<int,int>&uId )
  • QTabletEvent ( constQPoint&pos, constQPoint&globalPos, intdevice, intpressure, intxTilt, intyTilt, constQPair<int,int>&uId )
  • int pressure () const
  • int xTilt () const
  • int yTilt () const
  • const QPoint & pos () const
  • const QPoint & globalPos () const
  • int x () const
  • int y () const
  • int globalX () const
  • int globalY () const
  • TabletDevice device () const
  • int isAccepted () const
  • void accept ()
  • void ignore ()
  • QPair<int, int> uniqueId ()

Detailed Description

The QTabletEvent class contains parameters that describe a Tablet event.

Tablet Events are generated from a Wacom© tablet. Most of the time you will want to deal with events from the tablet as if they were events from a mouse, for example retrieving the position with x(), y(), pos(), globalX(), globalY() and globalPos(). In some situations you may wish to retrieve the extra information provided by the tablet device driver, for example, you might want to adjust color brightness based on pressure. QTabletEvent allows you to get the pressure(), the xTilt() and yTilt(), as well as the type of device being used with device() (see TabletDevice).

A tablet event contains a special 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 QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

The event handler QWidget::tabletEvent() receives tablet events.

See also Event Classes.


Member Type Documentation

QTabletEvent::TabletDevice

This enum defines what type of device is generating the event.

  • 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 (the narrow end of the pen).
  • QTabletEvent::Eraser - An Eraser (the broad end of the pen).

Member Function Documentation

QTabletEvent::QTabletEvent ( constQPoint&pos, intdevice, intpressure, intxTilt, intyTilt, constQPair<int,int>&uId )

Constructs a tablet event object.

The globalPos() is initialized to QCursor::pos(), i.e. pos, which is usually (but not always) correct. Use the other constructor if you need to specify the global position explicitly. device contains the device type, pressure contains the pressure exerted on the device, xTilt and yTilt contain the device's degrees of tilt from the X and Y axis respectively. The uId contains an event id.

See also pos(), device(), pressure(), xTilt() and yTilt().

QTabletEvent::QTabletEvent ( constQPoint&pos, constQPoint&globalPos, intdevice, intpressure, intxTilt, intyTilt, constQPair<int,int>&uId )

Constructs a tablet event object. The position when the event occurred is is given in pos and globalPos. device contains the device type, pressure contains the pressure exerted on the device, xTilt and yTilt contain the device's degrees of tilt from the X and Y axis respectively. The uId contains an event id.

On Irix, globalPos will contain the high-resolution coordinates received from the tablet device driver, instead of from the windowing system.

See also pos(), globalPos(), device(), pressure(), xTilt() and yTilt().

void QTabletEvent::accept ()

Sets the accept flag of the tablet event object.

Setting the accept flag indicates that the receiver of the event wants the tablet event. Unwanted tablet events are sent to the parent widget.

The accept flag is set by default.

See also ignore().

TabletDevice QTabletEvent::device () const

Returns the type of device that generated the event. Useful if you want one end of the pen to do something different than the other.

See also TabletDevice.

constQPoint& QTabletEvent::globalPos () const

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, globalPos() can differ significantly from the current position QCursor::pos().

See also globalX() and globalY().

int QTabletEvent::globalX () const

Returns the global x-position of the mouse pointer at the time of the event.

See also globalY() and globalPos().

int QTabletEvent::globalY () const

Returns the global y-position of the mouse pointer at the time of the event.

See also globalX() and globalPos().

void QTabletEvent::ignore ()

Clears the accept flag parameter of the tablet event object.

Clearing the accept flag indicates that the event receiver does not want the tablet event. Unwanted tablet events are sent to the parent widget.

The accept flag is set by default.

See also accept().

int QTabletEvent::isAccepted () const

Returns TRUE if the receiver of the event handles the tablet event; otherwise returns FALSE.

constQPoint& QTabletEvent::pos () const

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 x(), y() and globalPos().

int QTabletEvent::pressure () const

Returns the pressure that is exerted on the device. This number is a value from 0 (no pressure) to 255 (maximum pressure). The pressure is always scaled to be within this range no matter how many pressure levels the underlying hardware supports.

QPair<int,int> QTabletEvent::uniqueId ()

Returns a unique ID for the current device. It is possible to generate a unique ID for any Wacom© device. This makes it possible to differentiate between multiple devices being used at the same time on the tablet. The first member contains a value for the type, the second member contains a physical ID obtained from the device. Each combination of these values is unique. Note: for different platforms, the first value is different due to different driver implementations.

int QTabletEvent::x () const

Returns the x-position of the device, relative to the widget that received the event.

See also y() and pos().

int QTabletEvent::xTilt () const

Returns the difference from the perpendicular in the X Axis. Positive values are towards the tablet's physical right. The angle is in the range -60 to +60 degrees.

See also yTilt().

int QTabletEvent::y () const

Returns the y-position of the device, relative to the widget that received the event.

See also x() and pos().

int QTabletEvent::yTilt () const

Returns the difference from the perpendicular in the Y Axis. Positive values are towards the bottom of the tablet. The angle is within the range -60 to +60 degrees.

See also xTilt().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文