path: root/examples
diff options
authorFrederik Gladhorn <>2014-02-11 15:12:00 +0100
committerThe Qt Project <>2014-02-11 15:12:00 +0100
commitdf62c31807f7b0a8b9bc222b47ccc7016cfaee65 (patch)
treea7df6263cdb4cc96e2d31486437ec19ca0bf01e5 /examples
parent17de86f2824c1807c0fa7fa7ae0ed3b7d2acca00 (diff)
parenta1fe728fa5bd6cb9e50cf317a58efcf4eea4de2c (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/doc/images/basicgraphicslayouts-example.pngbin119062 -> 79461 bytes
-rw-r--r--examples/widgets/doc/images/basiclayouts-example.pngbin28406 -> 28771 bytes
-rw-r--r--examples/widgets/doc/images/draganddroppuzzle-example.pngbin191122 -> 259104 bytes
-rw-r--r--examples/widgets/doc/images/dropsite-example.pngbin118905 -> 36033 bytes
-rw-r--r--examples/widgets/doc/images/echopluginexample.pngbin5921 -> 10610 bytes
-rw-r--r--examples/widgets/doc/images/fridgemagnets-example.pngbin33012 -> 31707 bytes
-rw-r--r--examples/widgets/doc/images/graphicsanchorlayout-example.pngbin11592 -> 24372 bytes
-rw-r--r--examples/widgets/doc/images/graphicsflowlayout-example.pngbin15345 -> 18988 bytes
-rw-r--r--examples/widgets/doc/images/graphicssimpleanchorlayout-example.pngbin13715 -> 16743 bytes
-rw-r--r--examples/widgets/doc/images/itemviewspuzzle-example.pngbin211091 -> 196251 bytes
-rw-r--r--examples/widgets/doc/images/mainwindow-demo.pngbin62759 -> 85771 bytes
-rw-r--r--examples/widgets/doc/images/mousebutton-buttontester.pngbin14492 -> 17428 bytes
-rw-r--r--examples/widgets/gestures/ (renamed from examples/gestures/
-rw-r--r--examples/widgets/gestures/imagegestures/ (renamed from examples/gestures/imagegestures/
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.cpp (renamed from examples/gestures/imagegestures/imagewidget.cpp)0
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.h (renamed from examples/gestures/imagegestures/imagewidget.h)0
-rw-r--r--examples/widgets/gestures/imagegestures/main.cpp (renamed from examples/gestures/imagegestures/main.cpp)0
-rw-r--r--examples/widgets/gestures/imagegestures/mainwidget.cpp (renamed from examples/gestures/imagegestures/mainwidget.cpp)0
-rw-r--r--examples/widgets/gestures/imagegestures/mainwidget.h (renamed from examples/gestures/imagegestures/mainwidget.h)0
26 files changed, 119 insertions, 19 deletions
diff --git a/examples/ b/examples/
index b0f59c2020..79d8d14fce 100644
--- a/examples/
+++ b/examples/
@@ -4,7 +4,6 @@ CONFIG += no_docs_target
dbus \
embedded \
- gestures \
gui \
ipc \
json \
diff --git a/examples/network/doc/src/fortuneclient.qdoc b/examples/network/doc/src/fortuneclient.qdoc
index bf208475a8..01acf45837 100644
--- a/examples/network/doc/src/fortuneclient.qdoc
+++ b/examples/network/doc/src/fortuneclient.qdoc
@@ -63,7 +63,7 @@
In this example, we will demonstrate the asynchronous approach. The
- \l{blockingfortuneclient}{Blocking Fortune Client} example
+ \l{blockingfortuneclient}{Blocking Fortune Client Example}
illustrates the synchronous approach.
Our class contains some data and a few private slots:
diff --git a/examples/network/doc/src/fortuneserver.qdoc b/examples/network/doc/src/fortuneserver.qdoc
index 022e16a9d7..fd61f864f0 100644
--- a/examples/network/doc/src/fortuneserver.qdoc
+++ b/examples/network/doc/src/fortuneserver.qdoc
@@ -33,7 +33,7 @@
This example is intended to be run alongside the
\l{fortuneclient}{Fortune Client} example or the
- \l{blockingfortuneclient}{Blocking Fortune Client} example.
+ \l{blockingfortuneclient}{Blocking Fortune Client Example}.
\image fortuneserver-example.png Screenshot of the Fortune Server example
diff --git a/examples/threads/doc/src/mandelbrot.qdoc b/examples/threads/doc/src/mandelbrot.qdoc
index 6a9d0da193..c1393769f1 100644
--- a/examples/threads/doc/src/mandelbrot.qdoc
+++ b/examples/threads/doc/src/mandelbrot.qdoc
@@ -47,7 +47,7 @@
large set of problems, including synchronous network I/O and
database access, where the user interface must remain responsive
while some heavy operation is taking place. The \l
- network/blockingfortuneclient example shows the same principle at
+ {Blocking Fortune Client Example} shows the same principle at
work in a TCP client.
The Mandelbrot application supports zooming and scrolling using
diff --git a/examples/widgets/doc/images/basicgraphicslayouts-example.png b/examples/widgets/doc/images/basicgraphicslayouts-example.png
index 5c8f4cbc5d..6b8b39090f 100644
--- a/examples/widgets/doc/images/basicgraphicslayouts-example.png
+++ b/examples/widgets/doc/images/basicgraphicslayouts-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/basiclayouts-example.png b/examples/widgets/doc/images/basiclayouts-example.png
index f293423a8e..4a1c45dd80 100644
--- a/examples/widgets/doc/images/basiclayouts-example.png
+++ b/examples/widgets/doc/images/basiclayouts-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/draganddroppuzzle-example.png b/examples/widgets/doc/images/draganddroppuzzle-example.png
index 812278210d..ca6844581e 100644
--- a/examples/widgets/doc/images/draganddroppuzzle-example.png
+++ b/examples/widgets/doc/images/draganddroppuzzle-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/dropsite-example.png b/examples/widgets/doc/images/dropsite-example.png
index 42b988d733..2c42c7be69 100644
--- a/examples/widgets/doc/images/dropsite-example.png
+++ b/examples/widgets/doc/images/dropsite-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/echopluginexample.png b/examples/widgets/doc/images/echopluginexample.png
index 7cb1e4d63b..24e039714f 100644
--- a/examples/widgets/doc/images/echopluginexample.png
+++ b/examples/widgets/doc/images/echopluginexample.png
Binary files differ
diff --git a/examples/widgets/doc/images/fridgemagnets-example.png b/examples/widgets/doc/images/fridgemagnets-example.png
index 9adb572afc..2a890aad4e 100644
--- a/examples/widgets/doc/images/fridgemagnets-example.png
+++ b/examples/widgets/doc/images/fridgemagnets-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/graphicsanchorlayout-example.png b/examples/widgets/doc/images/graphicsanchorlayout-example.png
index d30d6839d9..3f35fdb6b7 100644
--- a/examples/widgets/doc/images/graphicsanchorlayout-example.png
+++ b/examples/widgets/doc/images/graphicsanchorlayout-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/graphicsflowlayout-example.png b/examples/widgets/doc/images/graphicsflowlayout-example.png
index a5f9b3dc40..953d54086a 100644
--- a/examples/widgets/doc/images/graphicsflowlayout-example.png
+++ b/examples/widgets/doc/images/graphicsflowlayout-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
index d073b12c0c..543670e05c 100644
--- a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
+++ b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/itemviewspuzzle-example.png b/examples/widgets/doc/images/itemviewspuzzle-example.png
index 05ae28be81..aae6a953ca 100644
--- a/examples/widgets/doc/images/itemviewspuzzle-example.png
+++ b/examples/widgets/doc/images/itemviewspuzzle-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/mainwindow-demo.png b/examples/widgets/doc/images/mainwindow-demo.png
index 5799dc0fa3..0e146d156e 100644
--- a/examples/widgets/doc/images/mainwindow-demo.png
+++ b/examples/widgets/doc/images/mainwindow-demo.png
Binary files differ
diff --git a/examples/widgets/doc/images/mousebutton-buttontester.png b/examples/widgets/doc/images/mousebutton-buttontester.png
index 82fcb7617f..f8f71db59b 100644
--- a/examples/widgets/doc/images/mousebutton-buttontester.png
+++ b/examples/widgets/doc/images/mousebutton-buttontester.png
Binary files differ
diff --git a/examples/widgets/doc/src/plugandpaint.qdoc b/examples/widgets/doc/src/plugandpaint.qdoc
index bfb763b7d1..4e48245bd9 100644
--- a/examples/widgets/doc/src/plugandpaint.qdoc
+++ b/examples/widgets/doc/src/plugandpaint.qdoc
@@ -47,9 +47,9 @@
If you want to learn how to make your own application extensible
through plugins, we recommend that you start by reading this
overview, which explains how to make an application use plugins.
- Afterward, you can read the
+ Afterwards, you can read the
\l{tools/plugandpaintplugins/basictools}{Basic Tools} and
- \l{plugandpaintplugins/extrafilters}{Extra Filters}
+ \l{tools/plugandpaintplugins/extrafilters}{Extra Filters}
overviews, which show how to implement static and dynamic
plugins, respectively.
@@ -126,8 +126,8 @@
a good idea to include a version number in the string, as we did
- The \l{plugandpaintplugins/basictools}{Basic Tools} plugin
- and the \l{plugandpaintplugins/extrafilters}{Extra Filters}
+ The \l{tools/plugandpaintplugins/basictools}{Basic Tools} plugin
+ and the \l{tools/plugandpaintplugins/extrafilters}{Extra Filters}
plugin shows how to derive from \c BrushInterface, \c
ShapeInterface, and \c FilterInterface.
@@ -275,7 +275,7 @@
\section1 Importing Static Plugins
- The \l{plugandpaintplugins/basictools}{Basic Tools} plugin
+ The \l{tools/plugandpaintplugins/basictools}{Basic Tools} plugin
is built as a static plugin, to ensure that it is always
available to the application. This requires using the
Q_IMPORT_PLUGIN() macro somewhere in the application (in a \c
@@ -307,7 +307,7 @@
This completes our review of the Plug & Paint application. At
this point, you might want to take a look at the
- \l{plugandpaintplugins/basictools}{Basic Tools} example
+ \l{tools/plugandpaintplugins/basictools}{Basic Tools} example
@@ -316,7 +316,7 @@
\title Plug & Paint Basic Tools Example
The Basic Tools example is a static plugin for the
- \l{plugandpaint}{Plug & Paint} example. It provides a set
+ \l{tools/plugandpaint}{Plug & Paint} example. It provides a set
of basic brushes, shapes, and filters. Through the Basic Tools
example, we will review the four steps involved in writing a Qt
@@ -333,7 +333,7 @@
\snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 0
We start by including \c interfaces.h, which defines the plugin
- interfaces for the \l{plugandpaint}{Plug & Paint}
+ interfaces for the \l{tools/plugandpaint}{Plug & Paint}
application. For the \c #include to work, we need to add an \c
INCLUDEPATH entry to the \c .pro file with the path to Qt's \c
examples/tools directory.
@@ -344,7 +344,7 @@
The \c Q_INTERFACES() macro is necessary to tell \l{moc}, Qt's
meta-object compiler, that the base classes are plugin
interfaces. Without the \c Q_INTERFACES() macro, we couldn't use
- \l qobject_cast() in the \l{plugandpaint}{Plug & Paint}
+ \l qobject_cast() in the \l{tools/plugandpaint}{Plug & Paint}
application to detect interfaces.
For an explanation for the \c Q_PLUGIN_METADATA() macro see
\l {Exporting the Plugin}.
@@ -473,7 +473,7 @@
To make the plugin a static plugin, all that is required is to
specify \c static in addition to \c plugin. The
- \l{plugandpaintplugins/extrafilters}{Extra Filters} plugin,
+ \l{tools/plugandpaintplugins/extrafilters}{Extra Filters} plugin,
which is compiled as a dynamic plugin, doesn't specify \c static
in its \c .pro file.
@@ -501,15 +501,15 @@
\title Plug & Paint Extra Filters Example
The Extra Filters example is a plugin for the
- \l{plugandpaint}{Plug & Paint} example. It provides a set
+ \l{tools/plugandpaint}{Plug & Paint} example. It provides a set
of filters in addition to those provided by the
- \l{plugandpaintplugins/basictools}{Basic Tools} plugin.
+ \l{tools/plugandpaintplugins/basictools}{Basic Tools} plugin.
Since the approach is identical to
- \l{plugandpaintplugins/basictools}{Basic Tools}, we won't
+ \l{tools/plugandpaintplugins/basictools}{Basic Tools}, we won't
review the code here. The only part of interest is the
\c .pro file, since Extra Filters is a dynamic plugin
- (\l{plugandpaintplugins/basictools}{Basic Tools} is
+ (\l{tools/plugandpaintplugins/basictools}{Basic Tools} is
linked statically into the Plug & Paint executable).
Here's the project file for building the Extra Filters plugin:
diff --git a/examples/gestures/ b/examples/widgets/gestures/
index ecbcf07480..ecbcf07480 100644
--- a/examples/gestures/
+++ b/examples/widgets/gestures/
diff --git a/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc b/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
new file mode 100644
index 0000000000..d6d215d6bd
--- /dev/null
+++ b/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
@@ -0,0 +1,100 @@
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact:
+** This file is part of the documentation of the Qt Toolkit.
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see For further information
+** use the contact form at
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met:
+ \example gestures/imagegestures
+ \title Image Gestures Example
+ This example shows how to enable gestures for a widget and use gesture input
+ to perform actions.
+ We use two classes to create the user interface for the application: \c MainWidget
+ and \c ImageWidget. The \c MainWidget class is simply used as a container for the
+ \c ImageWidget class, which we will configure to accept gesture input. Since we
+ are interested in the way gestures are used, we will concentrate on the
+ implementation of the \c ImageWidget class.
+ \section1 ImageWidget Class Definition
+ The \c ImageWidget class is a simple QWidget subclass that reimplements the general
+ QWidget::event() handler function in addition to several more specific event handlers:
+ \snippet gestures/imagegestures/imagewidget.h class definition begin
+ \dots
+ \snippet gestures/imagegestures/imagewidget.h class definition end
+ We also implement a private helper function, \c gestureEvent(), to help manage
+ gesture events delivered to the widget, and three functions to perform actions
+ based on gestures: \c panTriggered(), \c pinchTriggered() and \c swipeTriggered().
+ \section1 ImageWidget Class Implementation
+ In the widget's constructor, we begin by setting up various parameters that will
+ be used to control the way images are displayed.
+ \snippet gestures/imagegestures/imagewidget.cpp constructor
+ We enable three of the standard gestures for the widget by calling QWidget::grabGesture()
+ with the types of gesture we need. These will be recognized by the application's
+ default gesture recognizer, and events will be delivered to our widget.
+ Since QWidget does not define a specific event handler for gestures, the widget
+ needs to reimplement the general QWidget::event() to receive gesture events.
+ \snippet gestures/imagegestures/imagewidget.cpp event handler
+ We implement the event handler to delegate gesture events to a private function
+ specifically written for the task, and pass all other events to QWidget's
+ implementation.
+ The \c gestureHandler() function examines the gestures supplied by the
+ newly-delivered QGestureEvent. Since only one gesture of a given type can be
+ used on a widget at any particular time, we can check for each gesture type
+ using the QGestureEvent::gesture() function:
+ \snippet gestures/imagegestures/imagewidget.cpp gesture event handler
+ If a QGesture object is supplied for a certain type of gesture, we call a special
+ purpose function to deal with it, casting the gesture object to the appropriate
+ QGesture subclass.
+ To illustrate how a standard gesture can be interpreted by an application, we
+ show the implementation of the \c swipeTriggered() function, which handles the
+ gesture associated with a brushing or swiping motion on the user's display or
+ input device:
+ \snippet gestures/imagegestures/imagewidget.cpp swipe function
+ The QSwipeGesture class provides specialized functions and defines a enum
+ to make it more convenient for developers to discover which direction, if
+ any, the user swiped the display. Here, we simply navigate to the previous
+ image in the collection if the user swiped upwards or to the left; otherwise
+ we navigate to the next image in the collection.
+ The other gestures are also handled by special purpose functions, but use
+ the values of properties held by the QGesture object passed to them.
diff --git a/examples/gestures/imagegestures/ b/examples/widgets/gestures/imagegestures/
index c40c29564f..0d5b2f286c 100644
--- a/examples/gestures/imagegestures/
+++ b/examples/widgets/gestures/imagegestures/
@@ -7,6 +7,6 @@ SOURCES = imagewidget.cpp \
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/gestures/imagegestures
INSTALLS += target
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp
index aad40afc26..aad40afc26 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp
diff --git a/examples/gestures/imagegestures/imagewidget.h b/examples/widgets/gestures/imagegestures/imagewidget.h
index 7aaf554117..7aaf554117 100644
--- a/examples/gestures/imagegestures/imagewidget.h
+++ b/examples/widgets/gestures/imagegestures/imagewidget.h
diff --git a/examples/gestures/imagegestures/main.cpp b/examples/widgets/gestures/imagegestures/main.cpp
index aec32149f0..aec32149f0 100644
--- a/examples/gestures/imagegestures/main.cpp
+++ b/examples/widgets/gestures/imagegestures/main.cpp
diff --git a/examples/gestures/imagegestures/mainwidget.cpp b/examples/widgets/gestures/imagegestures/mainwidget.cpp
index 105cdf184e..105cdf184e 100644
--- a/examples/gestures/imagegestures/mainwidget.cpp
+++ b/examples/widgets/gestures/imagegestures/mainwidget.cpp
diff --git a/examples/gestures/imagegestures/mainwidget.h b/examples/widgets/gestures/imagegestures/mainwidget.h
index 5135466fde..5135466fde 100644
--- a/examples/gestures/imagegestures/mainwidget.h
+++ b/examples/widgets/gestures/imagegestures/mainwidget.h
diff --git a/examples/widgets/ b/examples/widgets/
index 9c82ad0bb7..d7d3dbc445 100644
--- a/examples/widgets/
+++ b/examples/widgets/
@@ -9,6 +9,7 @@ SUBDIRS = \
dialogs \
draganddrop \
effects \
+ gestures \
graphicsview \
itemviews \
layouts \