Qt 4.8
Public Functions | Private Functions | Friends | List of all members
QGestureEvent Class Reference

The QGestureEvent class provides the description of triggered gestures. More...

#include <qevent.h>

Inheritance diagram for QGestureEvent:
QEvent

Public Functions

void accept (QGesture *)
 Sets the accept flag of the given gesture object, the equivalent of calling setAccepted(gesture, true). More...
 
void accept (Qt::GestureType)
 Sets the accept flag of the given gestureType, the equivalent of calling setAccepted(gestureType, true). More...
 
QList< QGesture * > activeGestures () const
 Returns a list of active (not canceled) gestures. More...
 
QList< QGesture * > canceledGestures () const
 Returns a list of canceled gestures. More...
 
QGesturegesture (Qt::GestureType type) const
 Returns a gesture object by type. More...
 
QList< QGesture * > gestures () const
 Returns all gestures that are delivered in the event. More...
 
void ignore (QGesture *)
 Clears the accept flag parameter of the given gesture object, the equivalent of calling setAccepted(gesture, false). More...
 
void ignore (Qt::GestureType)
 Clears the accept flag parameter of the given gestureType, the equivalent of calling setAccepted(gesture, false). More...
 
bool isAccepted (QGesture *) const
 Returns true if the gesture is accepted; otherwise returns false. More...
 
bool isAccepted (Qt::GestureType) const
 Returns true if the gesture of type gestureType is accepted; otherwise returns false. More...
 
QPointF mapToGraphicsScene (const QPointF &gesturePoint) const
 Returns the scene-local coordinates if the gesturePoint is inside a graphics view. More...
 
 QGestureEvent (const QList< QGesture *> &gestures)
 Creates new QGestureEvent containing a list of gestures. More...
 
void setAccepted (QGesture *, bool)
 Sets the accept flag of the given gesture object to the specified value. More...
 
void setAccepted (Qt::GestureType, bool)
 Sets the accept flag of the given gestureType object to the specified value. More...
 
void setWidget (QWidget *widget)
 Sets the widget for this event to the widget specified. More...
 
QWidgetwidget () const
 Returns the widget on which the event occurred. More...
 
 ~QGestureEvent ()
 Destroys QGestureEvent. More...
 
- Public Functions inherited from QEvent
void accept ()
 Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More...
 
void ignore ()
 Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More...
 
bool isAccepted () const
 
 QEvent (Type type)
 Contructs an event object of type type. More...
 
void setAccepted (bool accepted)
 
bool spontaneous () const
 Returns true if the event originated outside the application (a system event); otherwise returns false. More...
 
Type type () const
 Returns the event type. More...
 
virtual ~QEvent ()
 Destroys the event. More...
 

Private Functions

QGestureEventPrivated_func ()
 
const QGestureEventPrivated_func () const
 

Friends

class QApplication
 
class QGestureManager
 

Additional Inherited Members

- Public Types inherited from QEvent
enum  Type {
  None = 0, Timer = 1, MouseButtonPress = 2, MouseButtonRelease = 3,
  MouseButtonDblClick = 4, MouseMove = 5, KeyPress = 6, KeyRelease = 7,
  FocusIn = 8, FocusOut = 9, Enter = 10, Leave = 11,
  Paint = 12, Move = 13, Resize = 14, Create = 15,
  Destroy = 16, Show = 17, Hide = 18, Close = 19,
  Quit = 20, ParentChange = 21, ParentAboutToChange = 131, ThreadChange = 22,
  WindowActivate = 24, WindowDeactivate = 25, ShowToParent = 26, HideToParent = 27,
  Wheel = 31, WindowTitleChange = 33, WindowIconChange = 34, ApplicationWindowIconChange = 35,
  ApplicationFontChange = 36, ApplicationLayoutDirectionChange = 37, ApplicationPaletteChange = 38, PaletteChange = 39,
  Clipboard = 40, Speech = 42, MetaCall = 43, SockAct = 50,
  WinEventAct = 132, DeferredDelete = 52, DragEnter = 60, DragMove = 61,
  DragLeave = 62, Drop = 63, DragResponse = 64, ChildAdded = 68,
  ChildPolished = 69, ChildRemoved = 71, ShowWindowRequest = 73, PolishRequest = 74,
  Polish = 75, LayoutRequest = 76, UpdateRequest = 77, UpdateLater = 78,
  EmbeddingControl = 79, ActivateControl = 80, DeactivateControl = 81, ContextMenu = 82,
  InputMethod = 83, AccessibilityPrepare = 86, TabletMove = 87, LocaleChange = 88,
  LanguageChange = 89, LayoutDirectionChange = 90, Style = 91, TabletPress = 92,
  TabletRelease = 93, OkRequest = 94, HelpRequest = 95, IconDrag = 96,
  FontChange = 97, EnabledChange = 98, ActivationChange = 99, StyleChange = 100,
  IconTextChange = 101, ModifiedChange = 102, MouseTrackingChange = 109, WindowBlocked = 103,
  WindowUnblocked = 104, WindowStateChange = 105, ToolTip = 110, WhatsThis = 111,
  StatusTip = 112, ActionChanged = 113, ActionAdded = 114, ActionRemoved = 115,
  FileOpen = 116, Shortcut = 117, ShortcutOverride = 51, WhatsThisClicked = 118,
  ToolBarChange = 120, ApplicationActivate = 121, ApplicationActivated = ApplicationActivate, ApplicationDeactivate = 122,
  ApplicationDeactivated = ApplicationDeactivate, QueryWhatsThis = 123, EnterWhatsThisMode = 124, LeaveWhatsThisMode = 125,
  ZOrderChange = 126, HoverEnter = 127, HoverLeave = 128, HoverMove = 129,
  AccessibilityHelp = 119, AccessibilityDescription = 130, AcceptDropsChange = 152, MenubarUpdated = 153,
  ZeroTimerEvent = 154, GraphicsSceneMouseMove = 155, GraphicsSceneMousePress = 156, GraphicsSceneMouseRelease = 157,
  GraphicsSceneMouseDoubleClick = 158, GraphicsSceneContextMenu = 159, GraphicsSceneHoverEnter = 160, GraphicsSceneHoverMove = 161,
  GraphicsSceneHoverLeave = 162, GraphicsSceneHelp = 163, GraphicsSceneDragEnter = 164, GraphicsSceneDragMove = 165,
  GraphicsSceneDragLeave = 166, GraphicsSceneDrop = 167, GraphicsSceneWheel = 168, KeyboardLayoutChange = 169,
  DynamicPropertyChange = 170, TabletEnterProximity = 171, TabletLeaveProximity = 172, NonClientAreaMouseMove = 173,
  NonClientAreaMouseButtonPress = 174, NonClientAreaMouseButtonRelease = 175, NonClientAreaMouseButtonDblClick = 176, MacSizeChange = 177,
  ContentsRectChange = 178, MacGLWindowChange = 179, FutureCallOut = 180, GraphicsSceneResize = 181,
  GraphicsSceneMove = 182, CursorChange = 183, ToolTipChange = 184, NetworkReplyUpdated = 185,
  GrabMouse = 186, UngrabMouse = 187, GrabKeyboard = 188, UngrabKeyboard = 189,
  MacGLClearDrawable = 191, StateMachineSignal = 192, StateMachineWrapped = 193, TouchBegin = 194,
  TouchUpdate = 195, TouchEnd = 196, NativeGesture = 197, RequestSoftwareInputPanel = 199,
  CloseSoftwareInputPanel = 200, UpdateSoftKeys = 201, WinIdChange = 203, Gesture = 198,
  GestureOverride = 202, PlatformPanel = 212, User = 1000, MaxUser = 65535
}
 This enum type defines the valid event types in Qt. More...
 
- Static Public Functions inherited from QEvent
static int registerEventType (int hint=-1)
 Registers and returns a custom event type. More...
 
- Protected Variables inherited from QEvent
QEventPrivate * d
 
ushort t
 

Detailed Description

The QGestureEvent class provides the description of triggered gestures.

Since
4.6

The QGestureEvent class contains a list of gestures, which can be obtained using the gestures() function.

The gestures are either active or canceled. A list of those that are currently being executed can be obtained using the activeGestures() function. A list of those which were previously active and have been canceled can be accessed using the canceledGestures() function. A gesture might be canceled if the current window loses focus, for example, or because of a timeout, or for other reasons.

If the event handler does not accept the event by calling the generic QEvent::accept() function, all individual QGesture object that were not accepted and in the Qt::GestureStarted state will be propagated up the parent widget chain until a widget accepts them individually, by calling QGestureEvent::accept() for each of them, or an event filter consumes the event.

Further Reading

For an overview of gesture handling in Qt and information on using gestures in your applications, see the Gestures Programming document.

See also
QGesture, QGestureRecognizer, QWidget::grabGesture(), QGraphicsObject::grabGesture()

Definition at line 841 of file qevent.h.

Constructors and Destructors

◆ QGestureEvent()

QGestureEvent::QGestureEvent ( const QList< QGesture *> &  gestures)

Creates new QGestureEvent containing a list of gestures.

Definition at line 4856 of file qevent.cpp.

4858 {
4859  d = reinterpret_cast<QEventPrivate *>(new QGestureEventPrivate(gestures));
4860 }
QEvent(Type type)
Contructs an event object of type type.
Definition: qcoreevent.cpp:289
QEventPrivate * d
Definition: qcoreevent.h:315

◆ ~QGestureEvent()

QGestureEvent::~QGestureEvent ( )

Destroys QGestureEvent.

Definition at line 4865 of file qevent.cpp.

4866 {
4867  delete reinterpret_cast<QGestureEventPrivate *>(d);
4868 }
QEventPrivate * d
Definition: qcoreevent.h:315

Functions

◆ accept() [1/2]

void QGestureEvent::accept ( QGesture gesture)

Sets the accept flag of the given gesture object, the equivalent of calling setAccepted(gesture, true).

Setting the accept flag indicates that the event receiver wants the gesture. Unwanted gestures may be propagated to the parent widget.

See also
QGestureEvent::ignore()

Definition at line 4944 of file qevent.cpp.

4945 {
4946  if (gesture)
4947  setAccepted(gesture->gestureType(), true);
4948 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70

◆ accept() [2/2]

void QGestureEvent::accept ( Qt::GestureType  gestureType)

Sets the accept flag of the given gestureType, the equivalent of calling setAccepted(gestureType, true).

Setting the accept flag indicates that the event receiver wants the gesture. Unwanted gestures may be propagated to the parent widget.

See also
QGestureEvent::ignore()

Definition at line 5003 of file qevent.cpp.

5004 {
5005  setAccepted(gestureType, true);
5006 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929

◆ activeGestures()

QList< QGesture * > QGestureEvent::activeGestures ( ) const

Returns a list of active (not canceled) gestures.

Definition at line 4893 of file qevent.cpp.

4894 {
4896  foreach (QGesture *gesture, d_func()->gestures) {
4897  if (gesture->state() != Qt::GestureCanceled)
4898  gestures.append(gesture);
4899  }
4900  return gestures;
4901 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QGesture * > gestures() const
Returns all gestures that are delivered in the event.
Definition: qevent.cpp:4873
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
QGesture * gesture(Qt::GestureType type) const
Returns a gesture object by type.
Definition: qevent.cpp:4881
Qt::GestureState state
the current state of the gesture
Definition: qgesture.h:69
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ canceledGestures()

QList< QGesture * > QGestureEvent::canceledGestures ( ) const

Returns a list of canceled gestures.

Definition at line 4906 of file qevent.cpp.

4907 {
4909  foreach (QGesture *gesture, d_func()->gestures) {
4910  if (gesture->state() == Qt::GestureCanceled)
4911  gestures.append(gesture);
4912  }
4913  return gestures;
4914 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QGesture * > gestures() const
Returns all gestures that are delivered in the event.
Definition: qevent.cpp:4873
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
QGesture * gesture(Qt::GestureType type) const
Returns a gesture object by type.
Definition: qevent.cpp:4881
Qt::GestureState state
the current state of the gesture
Definition: qgesture.h:69
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ d_func() [1/2]

QGestureEventPrivate * QGestureEvent::d_func ( )
private
Warning
This function is not part of the public interface.

Definition at line 5079 of file qevent.cpp.

Referenced by activeGestures(), canceledGestures(), gesture(), gestures(), isAccepted(), QApplication::notify(), setAccepted(), setWidget(), and widget().

5080 {
5081  return reinterpret_cast<QGestureEventPrivate *>(d);
5082 }
QEventPrivate * d
Definition: qcoreevent.h:315

◆ d_func() [2/2]

const QGestureEventPrivate * QGestureEvent::d_func ( ) const
private
Warning
This function is not part of the public interface.

Definition at line 5087 of file qevent.cpp.

5088 {
5089  return reinterpret_cast<const QGestureEventPrivate *>(d);
5090 }
QEventPrivate * d
Definition: qcoreevent.h:315

◆ gesture()

QGesture * QGestureEvent::gesture ( Qt::GestureType  type) const

Returns a gesture object by type.

Definition at line 4881 of file qevent.cpp.

Referenced by activeGestures(), canceledGestures(), QAbstractScrollArea::event(), QPlainTextEdit::event(), and QDeclarativeGestureAreaPrivate::gestureEvent().

4882 {
4883  const QGestureEventPrivate *d = d_func();
4884  for(int i = 0; i < d->gestures.size(); ++i)
4885  if (d->gestures.at(i)->gestureType() == type)
4886  return d->gestures.at(i);
4887  return 0;
4888 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QEventPrivate * d
Definition: qcoreevent.h:315
QList< QGesture * > gestures
Definition: qevent_p.h:167
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ gestures()

QList< QGesture * > QGestureEvent::gestures ( ) const

Returns all gestures that are delivered in the event.

Definition at line 4873 of file qevent.cpp.

Referenced by activeGestures(), canceledGestures(), QGestureManager::deliverEvents(), and QApplication::notify().

4874 {
4875  return d_func()->gestures;
4876 }
QList< QGesture * > gestures
Definition: qevent_p.h:167
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079

◆ ignore() [1/2]

void QGestureEvent::ignore ( QGesture gesture)

Clears the accept flag parameter of the given gesture object, the equivalent of calling setAccepted(gesture, false).

Clearing the accept flag indicates that the event receiver does not want the gesture. Unwanted gestures may be propagated to the parent widget.

See also
QGestureEvent::accept()

Definition at line 4959 of file qevent.cpp.

4960 {
4961  if (gesture)
4962  setAccepted(gesture->gestureType(), false);
4963 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70

◆ ignore() [2/2]

void QGestureEvent::ignore ( Qt::GestureType  gestureType)

Clears the accept flag parameter of the given gestureType, the equivalent of calling setAccepted(gesture, false).

Clearing the accept flag indicates that the event receiver does not want the gesture. Unwanted gestures may be propgated to the parent widget.

See also
QGestureEvent::accept()

Definition at line 5017 of file qevent.cpp.

5018 {
5019  setAccepted(gestureType, false);
5020 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929

◆ isAccepted() [1/2]

bool QGestureEvent::isAccepted ( QGesture gesture) const

Returns true if the gesture is accepted; otherwise returns false.

Definition at line 4968 of file qevent.cpp.

Referenced by QGraphicsScenePrivate::cancelGesturesForChildren(), QGestureManager::deliverEvents(), and QApplication::notify().

4969 {
4970  return gesture ? isAccepted(gesture->gestureType()) : false;
4971 }
bool isAccepted() const
Definition: qcoreevent.h:307
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70

◆ isAccepted() [2/2]

bool QGestureEvent::isAccepted ( Qt::GestureType  gestureType) const

Returns true if the gesture of type gestureType is accepted; otherwise returns false.

Definition at line 5026 of file qevent.cpp.

5027 {
5028  return d_func()->accepted.value(gestureType, true);
5029 }
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
QMap< Qt::GestureType, bool > accepted
Definition: qevent_p.h:169

◆ mapToGraphicsScene()

QPointF QGestureEvent::mapToGraphicsScene ( const QPointF gesturePoint) const

Returns the scene-local coordinates if the gesturePoint is inside a graphics view.

This functional might be useful when the gesture event is delivered to a QGraphicsObject to translate a point in screen coordinates to scene-local coordinates.

See also
QPointF::isNull().

Definition at line 5063 of file qevent.cpp.

5064 {
5065  QWidget *w = widget();
5066  if (w) // we get the viewport as widget, not the graphics view
5067  w = w->parentWidget();
5069  if (view) {
5070  return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint()));
5071  }
5072  return QPointF();
5073 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QWidget * widget() const
Returns the widget on which the event occurred.
Definition: qevent.cpp:5047
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64

◆ setAccepted() [1/2]

void QGestureEvent::setAccepted ( QGesture gesture,
bool  value 
)

Sets the accept flag of the given gesture object to the specified value.

Setting the accept flag indicates that the event receiver wants the gesture. Unwanted gestures may be propagated to the parent widget.

By default, gestures in events of type QEvent::Gesture are accepted, and gestures in QEvent::GestureOverride events are ignored.

For convenience, the accept flag can also be set with accept(gesture), and cleared with ignore(gesture).

Definition at line 4929 of file qevent.cpp.

Referenced by accept(), ignore(), QApplication::notify(), and setAccepted().

4930 {
4931  if (gesture)
4932  setAccepted(gesture->gestureType(), value);
4933 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70

◆ setAccepted() [2/2]

void QGestureEvent::setAccepted ( Qt::GestureType  gestureType,
bool  value 
)

Sets the accept flag of the given gestureType object to the specified value.

Setting the accept flag indicates that the event receiver wants to receive gestures of the specified type, gestureType. Unwanted gestures may be propagated to the parent widget.

By default, gestures in events of type QEvent::Gesture are accepted, and gestures in QEvent::GestureOverride events are ignored.

For convenience, the accept flag can also be set with accept(gestureType), and cleared with ignore(gestureType).

Definition at line 4988 of file qevent.cpp.

4989 {
4990  setAccepted(false);
4991  d_func()->accepted[gestureType] = value;
4992 }
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
QMap< Qt::GestureType, bool > accepted
Definition: qevent_p.h:169

◆ setWidget()

void QGestureEvent::setWidget ( QWidget widget)

Sets the widget for this event to the widget specified.

Warning
This function is not part of the public interface.

Definition at line 5039 of file qevent.cpp.

Referenced by QGraphicsScenePrivate::gestureEventHandler().

5040 {
5041  d_func()->widget = widget;
5042 }
QWidget * widget
Definition: qevent_p.h:168
QWidget * widget() const
Returns the widget on which the event occurred.
Definition: qevent.cpp:5047
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079

◆ widget()

QWidget * QGestureEvent::widget ( ) const

Returns the widget on which the event occurred.

Definition at line 5047 of file qevent.cpp.

Referenced by QGraphicsScenePrivate::gestureEventHandler(), mapToGraphicsScene(), and setWidget().

5048 {
5049  return d_func()->widget;
5050 }
QWidget * widget
Definition: qevent_p.h:168
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079

Friends and Related Functions

◆ QApplication

friend class QApplication
friend

Definition at line 887 of file qevent.h.

◆ QGestureManager

friend class QGestureManager
friend

Definition at line 888 of file qevent.h.


The documentation for this class was generated from the following files: