diff --git a/examples/widgets/gestures/imagegestures/imagegestures.pro b/examples/widgets/gestures/imagegestures/imagegestures.pro
index 0d5b2f2..ba30769 100644
--- a/examples/widgets/gestures/imagegestures/imagegestures.pro
+++ b/examples/widgets/gestures/imagegestures/imagegestures.pro
@@ -1,5 +1,5 @@
 QT += widgets
-
+CONFIG+=console
 HEADERS   = imagewidget.h \
             mainwidget.h
 SOURCES   = imagewidget.cpp \
diff --git a/examples/widgets/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp
index 3d0d7e7..5b21950 100644
--- a/examples/widgets/gestures/imagegestures/imagewidget.cpp
+++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp
@@ -166,6 +166,7 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture)
 //! [swipe function]
 void ImageWidget::swipeTriggered(QSwipeGesture *gesture)
 {
+    qDebug() << "####" << __FUNCTION__ << gesture;
     if (gesture->state() == Qt::GestureFinished) {
         if (gesture->horizontalDirection() == QSwipeGesture::Left
             || gesture->verticalDirection() == QSwipeGesture::Up) {
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index d19e473..d391bdc 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -286,26 +286,41 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
     QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
 
     switch (event->type()) {
+    case QEvent::TouchBegin:
+        case QEvent::TouchUpdate:
+        case    QEvent::TouchEnd:
+            qDebug() << __FUNCTION__ << event << "d->state=" << d->state;
+            break;
+    default:
+            break;
+    }
+
+    switch (event->type()) {
     case QEvent::TouchBegin: {
         d->velocityValue = 1;
         d->time.start();
         d->state = QSwipeGesturePrivate::Started;
         result = QGestureRecognizer::MayBeGesture;
+        qDebug() << __FUNCTION__ << "TouchBegin/MayBeGesture";
         break;
     }
     case QEvent::TouchEnd: {
         if (q->state() != Qt::NoGesture) {
+            qDebug() << __FUNCTION__ << "TouchEnd/FinishGesture";
             result = QGestureRecognizer::FinishGesture;
         } else {
+            qDebug() << __FUNCTION__ << "TouchEnd/CancelGesture";
             result = QGestureRecognizer::CancelGesture;
         }
         break;
     }
     case QEvent::TouchUpdate: {
         const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
-        if (d->state == QSwipeGesturePrivate::NoGesture)
+        if (d->state == QSwipeGesturePrivate::NoGesture) {
             result = QGestureRecognizer::CancelGesture;
-        else if (ev->touchPoints().size() == 3) {
+            qDebug() << __FUNCTION__ << "TouchUpdate in state CancelGesture";
+        } else if (ev->touchPoints().size() == 3) {
+            qDebug() << __FUNCTION__ << "TouchUpdate 3 points";
             d->state = QSwipeGesturePrivate::ThreePointsReached;
             QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
             QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
@@ -330,10 +345,17 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
             int elapsedTime = d->time.restart();
             if (!elapsedTime)
                 elapsedTime = 1;
+            const qreal oldV = d->velocityValue;
             d->velocityValue = 0.9 * d->velocityValue + (qreal) distance / elapsedTime;
-            d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle();
-
+             QLineF screenLineF(p1.startScreenPos(), p1.screenPos());
+            d->swipeAngle = screenLineF.angle();
             static const int MoveThreshold = 50;
+            qDebug() << __FUNCTION__ << "TouchUpdate " << screenLineF << "xDistance="
+                       << xDistance << "yDistance=" <<yDistance << "MoveThreshold=" <<MoveThreshold
+                       << "\n  oldVelocityValue=" << oldV << "velocityValue=" << d->velocityValue
+                       << "elapsedTime="<< elapsedTime << "distance / elapsedTime="
+                       << ((qreal) distance / elapsedTime)
+                       << "\n  swipeAngle=" << d->swipeAngle << "from (" << screenLineF.dx() << screenLineF.dy() <<')';
             if (qAbs(xDistance) > MoveThreshold || qAbs(yDistance) > MoveThreshold) {
                 // measure the distance to check if the direction changed
                 d->lastPositions[0] = p1.screenPos().toPoint();
@@ -347,9 +369,17 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
                     d->verticalDirection = vertical;
                 if (d->horizontalDirection == QSwipeGesture::NoDirection)
                     d->horizontalDirection = horizontal;
-                if (d->verticalDirection != vertical || d->horizontalDirection != horizontal) {
+                qDebug() << __FUNCTION__ << "TouchUpdate above threshold horizontalDirection="
+                         <<  horizontal << "d->horizontalDirection" << d->horizontalDirection
+                          << "verticalDirection=" << vertical << "d->verticalDirection=" <<d->verticalDirection;
+                if (d->verticalDirection != vertical) {
+                    qDebug() << "vertical direction change --> Cancel";
+                    result = QGestureRecognizer::CancelGesture;
+                } else if (d->horizontalDirection != horizontal) {
+                    qDebug() << "horizontal direction change --> Cancel";
                     result = QGestureRecognizer::CancelGesture;
                 } else {
+                    qDebug() << "trigger!";
                     result = QGestureRecognizer::TriggerGesture;
                 }
             } else {
@@ -357,8 +387,11 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
                     result = QGestureRecognizer::TriggerGesture;
                 else
                     result = QGestureRecognizer::MayBeGesture;
+                qDebug() << __FUNCTION__ << "TouchUpdate below threshold"  << result;
+
             }
         } else if (ev->touchPoints().size() > 3) {
+            qDebug() << __FUNCTION__ << "TouchUpdate > 3 points: CancelGesture";
             result = QGestureRecognizer::CancelGesture;
         } else { // less than 3 touch points
             switch (d->state) {
@@ -373,6 +406,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
                     ? QGestureRecognizer::CancelGesture : QGestureRecognizer::Ignore;
                 break;
             }
+            qDebug() << __FUNCTION__ << "TouchUpdate < 3 points" << result;
         }
         break;
     }
diff --git a/tests/manual/touch/touch.pro b/tests/manual/touch/touch.pro
index fcb3c47..be3ef1a 100644
--- a/tests/manual/touch/touch.pro
+++ b/tests/manual/touch/touch.pro
@@ -2,4 +2,5 @@ TEMPLATE = app
 QT = core gui
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 CONFIG -= app_bundle
+CONFIG+=console
 SOURCES += main.cpp
