source: trunk/doc/src/examples/imagegestures.qdoc@ 1168

Last change on this file since 1168 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \example gestures/imagegestures
30 \title Image Gestures Example
31
32 This example shows how to enable gestures for a widget and use gesture input
33 to perform actions.
34
35 We use two classes to create the user interface for the application: \c MainWidget
36 and \c ImageWidget. The \c MainWidget class is simply used as a container for the
37 \c ImageWidget class, which we will configure to accept gesture input. Since we
38 are interested in the way gestures are used, we will concentrate on the
39 implementation of the \c ImageWidget class.
40
41 \section1 ImageWidget Class Definition
42
43 The \c ImageWidget class is a simple QWidget subclass that reimplements the general
44 QWidget::event() handler function in addition to several more specific event handlers:
45
46 \snippet examples/gestures/imagegestures/imagewidget.h class definition begin
47 \dots
48 \snippet examples/gestures/imagegestures/imagewidget.h class definition end
49
50 We also implement a private helper function, \c gestureEvent(), to help manage
51 gesture events delivered to the widget, and three functions to perform actions
52 based on gestures: \c panTriggered(), \c pinchTriggered() and \c swipeTriggered().
53
54 \section1 ImageWidget Class Implementation
55
56 In the widget's constructor, we begin by setting up various parameters that will
57 be used to control the way images are displayed.
58
59 \snippet examples/gestures/imagegestures/imagewidget.cpp constructor
60
61 We enable three of the standard gestures for the widget by calling QWidget::grabGesture()
62 with the types of gesture we need. These will be recognized by the application's
63 default gesture recognizer, and events will be delivered to our widget.
64
65 Since QWidget does not define a specific event handler for gestures, the widget
66 needs to reimplement the general QWidget::event() to receive gesture events.
67