diff options
author | Thomas Zander <thomas.zander@trolltech.com> | 2009-10-19 17:11:19 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-22 14:59:19 (GMT) |
commit | 0f1f53414de3e7d1b62149ee42a334c6f2d01f78 (patch) | |
tree | 31594cd62f1224ba5d59896fa28c68f960cb8ef4 /src/gui/kernel/qevent.cpp | |
parent | 75599a71e957cae29ddd4d3df9e89d9d4edc0b3d (diff) | |
download | Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.zip Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.tar.gz Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.tar.bz2 |
Add QGestureEvent::mapToScene for better graphicsView integration
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 1c6a820..ef74f06 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -45,6 +45,7 @@ #include "private/qapplication_p.h" #include "private/qkeysequence_p.h" #include "qwidget.h" +#include "qgraphicsview.h" #include "qdebug.h" #include "qmime.h" #include "qdnd_p.h" @@ -4345,6 +4346,23 @@ QWidget *QGestureEvent::widget() const } /*! + Returns the scene-local coordinates if the \a gesturePoint is inside a graphics view. + + \sa QPointF::isNull(). +*/ +QPointF QGestureEvent::mapToScene(const QPointF &gesturePoint) const +{ + QWidget *w = widget(); + if (w) // we get the viewport as widget, not the graphics view + w = w->parentWidget(); + QGraphicsView *view = qobject_cast<QGraphicsView*>(w); + if (view) { + return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint())); + } + return QPointF(); +} + +/*! \internal */ QGestureEventPrivate *QGestureEvent::d_func() |