Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 5365

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qevent.cpp -->
<head>
  <title>Qt 4.6: QTouchEvent Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QTouchEvent"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QTouchEvent Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span>
</h1>
<p>The QTouchEvent class contains parameters that describe a touch event. <a href="#details">More...</a></p>
<pre> #include &lt;QTouchEvent&gt;</pre><p>Inherits <a href="qinputevent.html">QInputEvent</a>.</p>
<p>This class was introduced in Qt 4.6.</p>
<ul>
<li><a href="qtouchevent-members.html">List of all members, including inherited members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent-touchpoint.html">TouchPoint</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#DeviceType-enum">DeviceType</a></b> { TouchScreen, TouchPad }</td></tr>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#QTouchEvent">QTouchEvent</a></b> ( QEvent::Type <i>eventType</i>, QTouchEvent::DeviceType <i>deviceType</i> = TouchScreen, Qt::KeyboardModifiers <i>modifiers</i> = Qt::NoModifier, Qt::TouchPointStates <i>touchPointStates</i> = 0, const QList&lt;QTouchEvent::TouchPoint&gt; &amp; <i>touchPoints</i> = QList&lt;QTouchEvent::TouchPoint&gt; () )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#dtor.QTouchEvent">~QTouchEvent</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QTouchEvent::DeviceType </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#deviceType">deviceType</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Qt::TouchPointStates </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#touchPointStates">touchPointStates</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const QList&lt;QTouchEvent::TouchPoint&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#touchPoints">touchPoints</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QWidget * </td><td class="memItemRight" valign="bottom"><b><a href="qtouchevent.html#widget">widget</a></b> () const</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>1 public function inherited from <a href="qinputevent.html#public-functions">QInputEvent</a></li>
<li><div bar="2" class="fn"></div>6 public functions inherited from <a href="qevent.html#public-functions">QEvent</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>1 property inherited from <a href="qevent.html#properties">QEvent</a></li>
<li><div class="fn"></div>1 static public member inherited from <a href="qevent.html#static-public-members">QEvent</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QTouchEvent class contains parameters that describe a touch event.</p>
<a name="enabling-touch-events"></a>
<h3>Enabling Touch Events</h3>
<p>Touch events occur when pressing, releasing, or moving one or more touch points on a touch device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the <a href="qt.html#WidgetAttribute-enum">Qt::WA_AcceptTouchEvents</a> attribute set and graphics items need to have the <a href="qgraphicsitem.html#setAcceptTouchEvents">acceptTouchEvents</a> attribute set to true.</p>
<p>When using <a href="qabstractscrollarea.html">QAbstractScrollArea</a> based widgets, you should enable the <a href="qt.html#WidgetAttribute-enum">Qt::WA_AcceptTouchEvents</a> attribute on the scroll area's <a href="qabstractscrollarea.html#viewport">viewport</a>.</p>
<p>Similarly to <a href="qmouseevent.html">QMouseEvent</a>, Qt automatically grabs each touch point on the first press inside a widget, and the widget will receive all updates for the touch point until it is released. Note that it is possible for a widget to receive events for multiple touch points, and that multiple widgets may be receiving touch events at the same time.</p>
<a name="event-handling"></a>
<h3>Event Handling</h3>
<p>All touch events are of type <a href="qevent.html#Type-enum">QEvent::TouchBegin</a>, <a href="qevent.html#Type-enum">QEvent::TouchUpdate</a>, or <a href="qevent.html#Type-enum">QEvent::TouchEnd</a>. Reimplement <a href="qwidget.html#event">QWidget::event</a>() or <a href="qabstractscrollarea.html#viewportEvent">QAbstractScrollArea::viewportEvent</a>() for widgets and <a href="qgraphicsitem.html#sceneEvent">QGraphicsItem::sceneEvent</a>() for items in a graphics view to receive touch events.</p>
<p>The <a href="qevent.html#Type-enum">QEvent::TouchUpdate</a> and <a href="qevent.html#Type-enum">QEvent::TouchEnd</a> events are sent to the widget or item that accepted the <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event. If the <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event is not accepted and not filtered by an event filter, then no further touch events are sent until the next <a href="qevent.html#Type-enum">QEvent::TouchBegin</a>.</p>
<p>The <a href="qtouchevent.html#touchPoints">touchPoints</a>() function returns a list of all touch points contained in the event. Information about each touch point can be retrieved using the <a href="qtouchevent-touchpoint.html">QTouchEvent::TouchPoint</a> class. The <a href="qt.html#TouchPointState-enum">Qt::TouchPointState</a> enum describes the different states that a touch point may have.</p>
<a name="event-delivery-and-propagation"></a>
<h3>Event Delivery and Propagation</h3>
<p>By default, <a href="qwidget.html#event">QWidget::event</a>() translates the first non-primary touch point in a QTouchEvent into a <a href="qmouseevent.html">QMouseEvent</a>. This makes it possible to enable touch events on existing widgets that do not normally handle QTouchEvent. See below for information on some special considerations needed when doing this.</p>
<p><a href="qevent.html#Type-enum">QEvent::TouchBegin</a> is the first touch event sent to a widget. The <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event contains a special accept flag that indicates whether the receiver wants the event. By default, the event is accepted. You should call <a href="qevent.html#ignore">ignore</a>() if the touch event is not handled by your widget. The <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event is propagated up the parent widget chain until a widget accepts it with <a href="qevent.html#accept">accept</a>(), or an event filter consumes it. For QGraphicsItems, the <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event is propagated to items under the mouse (similar to mouse event propagation for QGraphicsItems).</p>
<a name="touch-point-grouping"></a>
<h3>Touch Point Grouping</h3>
<p>As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the same time. However, Qt makes sure to never send duplicate <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> events to the same widget, which could theoretically happen during propagation if, for example, the user touched 2 separate widgets in a <a href="qgroupbox.html">QGroupBox</a> and both widgets ignored the <a href="qevent.html#Type-enum">QEvent::TouchBegin</a> event.</p>
<p>To avoid this, Qt will group new touch points together using the following rules:</p>
<ul>
<li>When the first touch point is detected, the destination widget is determined firstly by the location on screen and secondly by the propagation rules.</li>
<li>When additional touch points are detected, Qt first looks to see if there are any active touch points on any ancestor or descendent of the widget under the new touch point. If there are, the new touch point is grouped with the first, and the new touch point will be sent in a single QTouchEvent to the widget that handled the first touch point. (The widget under the new touch point will not receive an event).</li>
</ul>
<p>This makes it possible for sibling widgets to handle touch events independently while making sure that the sequence of QTouchEvents is always correct.</p>
<a name="mouse-events-and-the-primary-touch-point"></a>
<h3>Mouse Events and the Primary Touch Point</h3>
<p>QTouchEvent delivery is independent from that of <a href="qmouseevent.html">QMouseEvent</a>. On some windowing systems, mouse events are also sent for the <a href="qtouchevent-touchpoint.html#isPrimary">primary touch point</a>. This means it is possible for your widget to receive both QTouchEvent and <a href="qmouseevent.html">QMouseEvent</a> for the same user interaction point. You can use the <a href="qtouchevent-touchpoint.html#isPrimary">QTouchEvent::TouchPoint::isPrimary</a>() function to identify the primary touch point.</p>
<p>Note that on some systems, it is possible to receive touch events without a primary touch point. All this means is that there will be no mouse event generated for the touch points in the QTouchEvent.</p>
<a name="caveats"></a>
<h3>Caveats</h3>
<ul>
<li>As mentioned above, enabling touch events means multiple widgets can be receiving touch events simultaneously. Combined with the default <a href="qwidget.html#event">QWidget::event</a>() handling for QTouchEvents, this gives you great flexibility in designing multi-touch user interfaces. Be aware of the implications. For example, it is possible that the user is moving a <a href="qslider.html">QSlider</a> with one finger and pressing a <a href="qpushbutton.html">QPushButton</a> with another. The signals emitted by these widgets will be interleaved.</li>
<li>Recursion into the event loop using one of the exec() methods (e.g&#x2e;, <a href="qdialog.html#exec">QDialog::exec</a>() or <a href="qmenu.html#exec">QMenu::exec</a>()) in a QTouchEvent event handler is not supported. Since there are multiple event recipients, recursion may cause problems, including but not limited to lost events and unexpected infinite recursion.</li>
<li>QTouchEvents are not affected by a <a href="qwidget.html#grabMouse">mouse grab</a> or an <a href="qapplication.html#activePopupWidget">active pop-up widget</a>. The behavior of QTouchEvents is undefined when opening a pop-up or grabbing the mouse while there are multiple active touch points.</li>
</ul>
<p>See also <a href="qtouchevent-touchpoint.html">QTouchEvent::TouchPoint</a>, <a href="qt.html#TouchPointState-enum">Qt::TouchPointState</a>, <a href="qt.html#WidgetAttribute-enum">Qt::WA_AcceptTouchEvents</a>, and <a href="qgraphicsitem.html#acceptTouchEvents">QGraphicsItem::acceptTouchEvents</a>().</p>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tag/QTouchEvent/DeviceType"></a>
<a name="//apple_ref/cpp/econst/QTouchEvent/TouchScreen"></a>
<a name="//apple_ref/cpp/econst/QTouchEvent/TouchPad"></a>
<h3 class="fn"><a name="DeviceType-enum"></a>enum QTouchEvent::DeviceType</h3>
<p>This enum represents the type of device that generated a <a href="qtouchevent.html">QTouchEvent</a>.</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QTouchEvent::TouchScreen</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">In this type of device, the touch surface and display are integrated. This means the surface and display typically have the same size, such that there is a direct relationship between the touch points' physical positions and the coordinate reported by <a href="qtouchevent-touchpoint.html">QTouchEvent::TouchPoint</a>. As a result, Qt allows the user to interact directly with multiple QWidgets and QGraphicsItems at the same time.</td></tr>
<tr><td valign="top"><tt>QTouchEvent::TouchPad</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">In this type of device, the touch surface is separate from the display. There is not a direct relationship between the physical touch location and the on-screen coordinates. Instead, they are calculated relative to the current mouse position, and the user must use the touch-pad to move this reference point. Unlike touch-screens, Qt allows users to only interact with a single <a href="qwidget.html">QWidget</a> or <a href="qgraphicsitem.html">QGraphicsItem</a> at a time.</td></tr>
</table></p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QTouchEvent/QTouchEvent"></a>
<h3 class="fn"><a name="QTouchEvent"></a>QTouchEvent::QTouchEvent ( <a href="qevent.html#Type-enum">QEvent::Type</a> <i>eventType</i>, <a href="qtouchevent.html#DeviceType-enum">QTouchEvent::DeviceType</a> <i>deviceType</i> = TouchScreen, <a href="qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a> <i>modifiers</i> = Qt::NoModifier, <a href="qt.html#TouchPointState-enum">Qt::TouchPointStates</a> <i>touchPointStates</i> = 0, const <a href="qlist.html">QList</a>&lt;<a href="qtouchevent-touchpoint.html">QTouchEvent::TouchPoint</a>&gt; &amp; <i>touchPoints</i> = QList&lt;QTouchEvent::TouchPoint&gt; () )</h3>
<p>Constructs a <a href="qtouchevent.html">QTouchEvent</a> with the given <i>eventType</i>, <i>deviceType</i>, and <i>touchPoints</i>. The <i>touchPointStates</i> and <i>modifiers</i> are the current touch point states and keyboard modifiers at the time of the event.</p>
<a name="//apple_ref/cpp/instm/QTouchEvent/~QTouchEvent"></a>
<h3 class="fn"><a name="dtor.QTouchEvent"></a>QTouchEvent::~QTouchEvent ()</h3>
<p>Destroys the <a href="qtouchevent.html">QTouchEvent</a>.</p>
<a name="//apple_ref/cpp/instm/QTouchEvent/deviceType"></a>
<h3 class="fn"><a name="deviceType"></a><a href="qtouchevent.html#DeviceType-enum">QTouchEvent::DeviceType</a> QTouchEvent::deviceType () const</h3>
<p>Returns the touch device Type, which is of type <a href="qtouchevent.html#DeviceType-enum">DeviceType</a>.</p>
<a name="//apple_ref/cpp/instm/QTouchEvent/touchPointStates"></a>
<h3 class="fn"><a name="touchPointStates"></a><a href="qt.html#TouchPointState-enum">Qt::TouchPointStates</a> QTouchEvent::touchPointStates () const</h3>
<p>Returns a bitwise OR of all the touch point states for this event.</p>
<a name="//apple_ref/cpp/instm/QTouchEvent/touchPoints"></a>
<h3 class="fn"><a name="touchPoints"></a>const <a href="qlist.html">QList</a>&lt;<a href="qtouchevent-touchpoint.html">QTouchEvent::TouchPoint</a>&gt; &amp; QTouchEvent::touchPoints () const</h3>
<p>Returns the list of touch points contained in the touch event.</p>
<a name="//apple_ref/cpp/instm/QTouchEvent/widget"></a>
<h3 class="fn"><a name="widget"></a><a href="qwidget.html">QWidget</a> * QTouchEvent::widget () const</h3>
<p>Returns the widget on which the event occurred.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>