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 172 173 174 175 176 177 178 179 180 181
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QGestureRecognizer Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGestureRecognizer Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGestureRecognizer class provides the infrastructure for
gesture recognition. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />class <b><a href="qgesturerecognizer-result.html">Result</a></b></li><li><div class="fn" />enum <b><a href="qgesturerecognizer.html#ResultFlag-enum">ResultFlag</a></b> { Ignore, MayBeGesture, TriggerGesture, FinishGesture, CancelGesture, ConsumeEventHint }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgesturerecognizer.html#QGestureRecognizer">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgesturerecognizer.html#QGestureRecognizer-2">__init__</a></b> (<i>self</i>, QGestureRecognizer)</li><li><div class="fn" />QGesture <b><a href="qgesturerecognizer.html#create">create</a></b> (<i>self</i>, QObject <i>target</i>)</li><li><div class="fn" />Result <b><a href="qgesturerecognizer.html#recognize">recognize</a></b> (<i>self</i>, QGesture <i>state</i>, QObject <i>watched</i>, QEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgesturerecognizer.html#reset">reset</a></b> (<i>self</i>, QGesture <i>state</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />Qt.GestureType <b><a href="qgesturerecognizer.html#registerRecognizer">registerRecognizer</a></b> (QGestureRecognizer <i>recognizer</i>)</li><li><div class="fn" /><b><a href="qgesturerecognizer.html#unregisterRecognizer">unregisterRecognizer</a></b> (Qt.GestureType <i>type</i>)</li></ul><a name="details" /><hr /><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 id="recognizing-gestures" name="recognizing-gestures" />
<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 id="supporting-new-gestures" name="supporting-new-gestures" />
<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>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ResultFlag-enum" />QGestureRecognizer.ResultFlag</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 class="odd" valign="top">
<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><ResultFlag>. It stores an OR
combination of ResultFlag values.</p>
<p><b>See also</b> <a href="qgesturerecognizer.html#recognize">QGestureRecognizer.recognize</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGestureRecognizer" />QGestureRecognizer.__init__ (<i>self</i>)</h3><p>Constructs a new gesture recognizer object.</p>
<h3 class="fn"><a name="QGestureRecognizer-2" />QGestureRecognizer.__init__ (<i>self</i>, <a href="qgesturerecognizer.html">QGestureRecognizer</a>)</h3><h3 class="fn"><a name="create" /><a href="qgesture.html">QGesture</a> QGestureRecognizer.create (<i>self</i>, <a href="qobject.html">QObject</a> <i>target</i>)</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>
<h3 class="fn"><a name="recognize" /><a href="qgesturerecognizer-result.html">Result</a> QGestureRecognizer.recognize (<i>self</i>, <a href="qgesture.html">QGesture</a> <i>state</i>, <a href="qobject.html">QObject</a> <i>watched</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><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>
<h3 class="fn"><a name="registerRecognizer" /><a href="qt.html#GestureType-enum">Qt.GestureType</a> QGestureRecognizer.registerRecognizer (<a href="qgesturerecognizer.html">QGestureRecognizer</a> <i>recognizer</i>)</h3><p>The <i>recognizer</i> argument has it's ownership transferred to Qt.</p><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., 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>
<h3 class="fn"><a name="reset" />QGestureRecognizer.reset (<i>self</i>, <a href="qgesture.html">QGesture</a> <i>state</i>)</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>
<h3 class="fn"><a name="unregisterRecognizer" />QGestureRecognizer.unregisterRecognizer (<a href="qt.html#GestureType-enum">Qt.GestureType</a> <i>type</i>)</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>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.11.4 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|