File: qgesturerecognizer.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (171 lines) | stat: -rw-r--r-- 17,338 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qgesturerecognizer.cpp -->
  <title>Qt 4.8: QGestureRecognizer Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QGestureRecognizer</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#recognizing-gestures">Recognizing Gestures</a></li>
<li class="level2"><a href="#supporting-new-gestures">Supporting New Gestures</a></li>
</ul>
</div>
<h1 class="title">QGestureRecognizer Class Reference</h1>
<!-- $$$QGestureRecognizer-brief -->
<p>The QGestureRecognizer class provides the infrastructure for gesture recognition. <a href="#details">More...</a></p>
<!-- @@@QGestureRecognizer -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QGestureRecognizer&gt;</span></pre><p>This class was introduced in Qt 4.6.</p>
<ul>
<li><a href="qgesturerecognizer-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#ResultFlag-enum">Result</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#ResultFlag-enum">ResultFlag</a></b> { Ignore, MayBeGesture, TriggerGesture, FinishGesture, CancelGesture, ConsumeEventHint }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#QGestureRecognizer">QGestureRecognizer</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#dtor.QGestureRecognizer">~QGestureRecognizer</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QGesture * </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#create">create</a></b> ( QObject * <i>target</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual Result </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#recognize">recognize</a></b> ( QGesture * <i>gesture</i>, QObject * <i>watched</i>, QEvent * <i>event</i> ) = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#reset">reset</a></b> ( QGesture * <i>gesture</i> )</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Qt::GestureType </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#registerRecognizer">registerRecognizer</a></b> ( QGestureRecognizer * <i>recognizer</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgesturerecognizer.html#unregisterRecognizer">unregisterRecognizer</a></b> ( Qt::GestureType <i>type</i> )</td></tr>
</table>
<a name="details"></a>
<!-- $$$QGestureRecognizer-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QGestureRecognizer class provides the infrastructure for gesture recognition.</p>
<p>Gesture recognizers are responsible for creating and managing <a href="qgesture.html">QGesture</a> objects and monitoring input events sent to <a href="qwidget.html">QWidget</a> and <a href="qgraphicsobject.html">QGraphicsObject</a> subclasses. QGestureRecognizer is the base class for implementing custom gestures.</p>
<p>Developers that only need to provide gesture recognition for standard gestures do not need to use this class directly. Instances will be created behind the scenes by the framework.</p>
<p>For an overview of gesture handling in Qt and information on using gestures in your applications, see the <a href="gestures-overview.html">Gestures Programming</a> document.</p>
<a name="recognizing-gestures"></a>
<h3>Recognizing Gestures</h3>
<p>The process of recognizing gestures involves filtering input events sent to specific objects, and modifying the associated <a href="qgesture.html">QGesture</a> objects to include relevant information about the user's input.</p>
<p>Gestures are created when the framework calls <a href="qgesturerecognizer.html#create">create</a>() to handle user input for a particular instance of a <a href="qwidget.html">QWidget</a> or <a href="qgraphicsobject.html">QGraphicsObject</a> subclass. A <a href="qgesture.html">QGesture</a> object is created for each widget or item that is configured to use gestures.</p>
<p>Once a <a href="qgesture.html">QGesture</a> has been created for a target object, the gesture recognizer will receive events for it in its <a href="qgesturerecognizer.html#recognize">recognize</a>() handler function.</p>
<p>When a gesture is canceled, the <a href="qgesturerecognizer.html#reset">reset</a>() function is called, giving the recognizer the chance to update the appropriate properties in the corresponding <a href="qgesture.html">QGesture</a> object.</p>
<a name="supporting-new-gestures"></a>
<h3>Supporting New Gestures</h3>
<p>To add support for new gestures, you need to derive from QGestureRecognizer to create a custom recognizer class, construct an instance of this class, and register it with the application by calling <a href="qgesturerecognizer.html#registerRecognizer">QGestureRecognizer::registerRecognizer</a>(). You can also subclass <a href="qgesture.html">QGesture</a> to create a custom gesture class, or rely on dynamic properties to express specific details of the gesture you want to handle.</p>
<p>Your custom QGestureRecognizer subclass needs to reimplement the <a href="qgesturerecognizer.html#recognize">recognize</a>() function to handle and filter the incoming input events for <a href="qwidget.html">QWidget</a> and <a href="qgraphicsobject.html">QGraphicsObject</a> subclasses. Although the logic for gesture recognition is implemented in this function, you can store persistent information about the state of the recognition process in the <a href="qgesture.html">QGesture</a> object supplied. The <a href="qgesturerecognizer.html#recognize">recognize</a>() function must return a value of <a href="qgesturerecognizer.html#ResultFlag-enum">QGestureRecognizer::Result</a> that indicates the state of recognition for a given gesture and target object. This determines whether or not a gesture event will be delivered to a target object.</p>
<p>If you choose to represent a gesture by a custom <a href="qgesture.html">QGesture</a> subclass, you will need to reimplement the <a href="qgesturerecognizer.html#create">create</a>() function to construct instances of your gesture class. Similarly, you may need to reimplement the <a href="qgesturerecognizer.html#reset">reset</a>() function if your custom gesture objects need to be specially handled when a gesture is canceled.</p>
</div>
<p><b>See also </b><a href="qgesture.html">QGesture</a>.</p>
<!-- @@@QGestureRecognizer -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ResultFlag$$$Ignore$$$MayBeGesture$$$TriggerGesture$$$FinishGesture$$$CancelGesture$$$ResultState_Mask$$$ConsumeEventHint$$$ResultHint_Mask -->
<h3 class="flags"><a name="ResultFlag-enum"></a>enum QGestureRecognizer::<span class="name">ResultFlag</span><br/>flags QGestureRecognizer::<span class="name">Result</span></h3>
<p>This enum describes the result of the current event filtering step in a gesture recognizer state machine.</p>
<p>The result consists of a state value (one of Ignore, MayBeGesture, TriggerGesture, FinishGesture, CancelGesture) and an optional hint (ConsumeEventHint).</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::Ignore</tt></td><td class="topAlign"><tt>0x0001</tt></td><td class="topAlign">The event does not change the state of the recognizer.</td></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::MayBeGesture</tt></td><td class="topAlign"><tt>0x0002</tt></td><td class="topAlign">The event changed the internal state of the recognizer, but it isn't clear yet if it is a gesture or not. The recognizer needs to filter more events to decide. Gesture recognizers in the MayBeGesture state may be reset automatically if they take too long to recognize gestures.</td></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::TriggerGesture</tt></td><td class="topAlign"><tt>0x0004</tt></td><td class="topAlign">The gesture has been triggered and the appropriate <a href="qgesture.html">QGesture</a> object will be delivered to the target as a part of a <a href="qgestureevent.html">QGestureEvent</a>.</td></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::FinishGesture</tt></td><td class="topAlign"><tt>0x0008</tt></td><td class="topAlign">The gesture has been finished successfully and the appropriate <a href="qgesture.html">QGesture</a> object will be delivered to the target as a part of a <a href="qgestureevent.html">QGestureEvent</a>.</td></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::CancelGesture</tt></td><td class="topAlign"><tt>0x0010</tt></td><td class="topAlign">The event made it clear that it is not a gesture. If the gesture recognizer was in GestureTriggered state before, then the gesture is canceled and the appropriate <a href="qgesture.html">QGesture</a> object will be delivered to the target as a part of a <a href="qgestureevent.html">QGestureEvent</a>.</td></tr>
<tr><td class="topAlign"><tt>QGestureRecognizer::ConsumeEventHint</tt></td><td class="topAlign"><tt>0x0100</tt></td><td class="topAlign">This hint specifies that the gesture framework should consume the filtered event and not deliver it to the receiver.</td></tr>
</table>
<p>The Result type is a typedef for <a href="qflags.html">QFlags</a>&lt;ResultFlag&gt;. It stores an OR combination of ResultFlag values.</p>
<p><b>See also </b><a href="qgesturerecognizer.html#recognize">QGestureRecognizer::recognize</a>().</p>
<!-- @@@ResultFlag -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QGestureRecognizer[overload1]$$$QGestureRecognizer -->
<h3 class="fn"><a name="QGestureRecognizer"></a>QGestureRecognizer::<span class="name">QGestureRecognizer</span> ()</h3>
<p>Constructs a new gesture recognizer object.</p>
<!-- @@@QGestureRecognizer -->
<!-- $$$~QGestureRecognizer[overload1]$$$~QGestureRecognizer -->
<h3 class="fn"><a name="dtor.QGestureRecognizer"></a>QGestureRecognizer::<span class="name">~QGestureRecognizer</span> ()<tt> [virtual]</tt></h3>
<p>Destroys the gesture recognizer.</p>
<!-- @@@~QGestureRecognizer -->
<!-- $$$create[overload1]$$$createQObject* -->
<h3 class="fn"><a name="create"></a><span class="type"><a href="qgesture.html">QGesture</a></span> * QGestureRecognizer::<span class="name">create</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>target</i> )<tt> [virtual]</tt></h3>
<p>This function is called by Qt to create a new <a href="qgesture.html">QGesture</a> object for the given <i>target</i> (<a href="qwidget.html">QWidget</a> or <a href="qgraphicsobject.html">QGraphicsObject</a>).</p>
<p>Reimplement this function to create a custom <a href="qgesture.html">QGesture</a>-derived gesture object if necessary.</p>
<p>The application takes ownership of the created gesture object.</p>
<!-- @@@create -->
<!-- $$$recognize[overload1]$$$recognizeQGesture*QObject*QEvent* -->
<h3 class="fn"><a name="recognize"></a><span class="type"><a href="qgesturerecognizer.html#ResultFlag-enum">Result</a></span> QGestureRecognizer::<span class="name">recognize</span> ( <span class="type"><a href="qgesture.html">QGesture</a></span> * <i>gesture</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>watched</i>, <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [pure virtual]</tt></h3>
<p>Handles the given <i>event</i> for the <i>watched</i> object, updating the state of the <i>gesture</i> object as required, and returns a suitable result for the current recognition step.</p>
<p>This function is called by the framework to allow the recognizer to filter input events dispatched to <a href="qwidget.html">QWidget</a> or <a href="qgraphicsobject.html">QGraphicsObject</a> instances that it is monitoring.</p>
<p>The result reflects how much of the gesture has been recognized. The state of the <i>gesture</i> object is set depending on the result.</p>
<p><b>See also </b><a href="qgesturerecognizer.html#ResultFlag-enum">QGestureRecognizer::Result</a>.</p>
<!-- @@@recognize -->
<!-- $$$registerRecognizer[overload1]$$$registerRecognizerQGestureRecognizer* -->
<h3 class="fn"><a name="registerRecognizer"></a><span class="type"><a href="qt.html#GestureType-enum">Qt::GestureType</a></span> QGestureRecognizer::<span class="name">registerRecognizer</span> ( <span class="type">QGestureRecognizer</span> * <i>recognizer</i> )<tt> [static]</tt></h3>
<p>Registers the given <i>recognizer</i> in the gesture framework and returns a gesture ID for it.</p>
<p>The application takes ownership of the <i>recognizer</i> and returns the gesture type ID associated with it. For gesture recognizers which handle custom <a href="qgesture.html">QGesture</a> objects (i.e&#x2e;, those which return <a href="qt.html#GestureType-enum">Qt::CustomGesture</a> in a <a href="qgesture.html#gestureType-prop">QGesture::gestureType</a>() function) the return value is a generated gesture ID with the <a href="qt.html#GestureType-enum">Qt::CustomGesture</a> flag set.</p>
<p><b>See also </b><a href="qgesturerecognizer.html#unregisterRecognizer">unregisterRecognizer</a>(), <a href="qgesturerecognizer.html#create">QGestureRecognizer::create</a>(), and <a href="qgesture.html">QGesture</a>.</p>
<!-- @@@registerRecognizer -->
<!-- $$$reset[overload1]$$$resetQGesture* -->
<h3 class="fn"><a name="reset"></a><span class="type">void</span> QGestureRecognizer::<span class="name">reset</span> ( <span class="type"><a href="qgesture.html">QGesture</a></span> * <i>gesture</i> )<tt> [virtual]</tt></h3>
<p>This function is called by the framework to reset a given <i>gesture</i>.</p>
<p>Reimplement this function to implement additional requirements for custom <a href="qgesture.html">QGesture</a> objects. This may be necessary if you implement a custom <a href="qgesture.html">QGesture</a> whose properties need special handling when the gesture is reset.</p>
<!-- @@@reset -->
<!-- $$$unregisterRecognizer[overload1]$$$unregisterRecognizerQt::GestureType -->
<h3 class="fn"><a name="unregisterRecognizer"></a><span class="type">void</span> QGestureRecognizer::<span class="name">unregisterRecognizer</span> ( <span class="type"><a href="qt.html#GestureType-enum">Qt::GestureType</a></span> <i>type</i> )<tt> [static]</tt></h3>
<p>Unregisters all gesture recognizers of the specified <i>type</i>.</p>
<p><b>See also </b><a href="qgesturerecognizer.html#registerRecognizer">registerRecognizer</a>().</p>
<!-- @@@unregisterRecognizer -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>