|Home · All Classes · Main Classes · Deprecated|
A gesture is a high-level event that represents a series of user input. Qt and MeeGo Touch support the following gestures:
|Pan||Press, drag, release||QPanGesture|
|Pinch||Press (with two fingers), move fingers on surface,|
optionally release one of the fingers and reposition, release
|Swipe||Press, quick drag and release||QSwipeGesture|
|Tap and hold||Press, wait||QTapAndHoldGesture|
As a gesture is merely an interpreted series of input, the application determines what the gesture actually means. For example, a pinch gesture may be used to either rotate or zoom a picture, or both. If combined, gestures may have overlapping interactions, as is the case of swipe and pan. It is up to the application design to make sure there are no overlapping interactions in UI (the result of overlapping interactions is undefined). Typically a swipe gesture would be used in a UI where a flick should be interpreted as "next" or "previous", while a pan gesture implies an event with acceleration such as scrolling a web page.
While all of the above gestures are touch-activated, gestures can potentially use any type of input such as key events or sensor data. You can use the QGestureRecognizer framework to register new custom gesture types.
The gesture events are generally not keeping track of the current screen orientation. The data delivered to widgets are in screen's coordinate space. The gesture event user is responsible for transforming event data to the current widget's coordinate space.
While gesture events are mainly meant for application consumption, the MeeGo Touch UI design guidelines specify some default actions based on gestures. Unless the application developer overrides the behaviour, gestures may be consumed by the framework itself in the following cases:
Gestures used in MeeGo Touch library are strongly connected to Cancel event. The Cancel event is an event specific to MeegGo Touch applications and is used to indicate that the sequence of mouse events delivered to a widget was generated by a gesture.
Typical example of such scenario is a button widget. The user starts panning gesture in order to view different area of the application and first presses his finger over a button. The sequence of events received by the button is:
When the button widget receives the Cancel event, it is supposed to remove any visual feedback enabled while mouse events were received without triggering any action. Received Cancel event means also that the mouse release event is not going to be delivered to the widget.
Check MWidget::grabGestureWithCancelPolicy method documentation for details on how to enable cancel event delivery for your widget.
While some of the gestures mentioned above (such as pinch) are implemented using multipoint touch events, by itself multipoint touch merely refers to the capability of detecting several fingers on the screen at once. Multipoint touch events are also directly accessible by applications in a low-level form comparable to mouse and key presses and releases, where the actual interpretation of the events is left entirely up to you. Note: Multipoint touch requires special hardware to function, since many touch input devices are not capable of detecting multiple touch points at once.
In Qt, multipoint-touch input is delivered through the QTouchEvent class, through which it is possible to determine all the currently touched screen points.
Note: Since multipoint touch events are not delivered to widgets by default, the delivery must be explicitly enabled with the QGraphicsItem::setAcceptTouchEvents method.
You can simulate the multipoint touch pinch gesture without real multipoint-touch hardware, for example, in a development environment on a standard PC. Simply hold down the <Ctrl> key on the keyboard, then press and drag with the left mouse button.
MeeGo Touch provides several event handlers for gestures:
Gestures are not delivered to widgets by default, gesture delivery is enabled by the QGraphicsObject::grabGesture method. Using this method will cause the framework to deliver gesture events, but the mouse press/move/release sequences will not be broken by the Cancel events. To enable it one should use MWidget::grabGestureWithCancelPolicy method, specifying also the policy for sending Cancel events.
MeeGo Touch currently replaces some of the default Qt gesture recognizers with versions capable of interpreting regular mouse events in addition to the touch events used by Qt. Pan and swipe are also one-finger gestures in MeeGo Touch, while they are two- and three-finger gestures, respectively, in Qt (as of version 4.7).
The examples/gestures directory of the MeeGo Touch source contains a sample application demonstrating proper use of gestures combined with MeeGo Touch widgets. The example is a gallery application, where pinching zooms and rotates the picture simultaneously, while swiping left or right changes the picture.
The example below illustrates the following:
Below is the example code relevant to the gestures:
|Copyright © 2010 Nokia Corporation||