summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2009-12-18 15:54:16 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2009-12-18 15:54:16 (GMT)
commit51be60532af93ac6526e76db4085283465c5baa6 (patch)
tree31528a8db677ffb21346fe26e317c75838d03f47 /src/gui/graphicsview
parent82a35ed3f1dede556e9ab6e30b86997c4a8f0fd1 (diff)
downloadQt-51be60532af93ac6526e76db4085283465c5baa6.zip
Qt-51be60532af93ac6526e76db4085283465c5baa6.tar.gz
Qt-51be60532af93ac6526e76db4085283465c5baa6.tar.bz2
Fixes bug when using AnchorUnderMouse for GraphicsView transformation.
We now automatically enable mouse tracking on the viewport of the GraphicsView when setting AnchorUnderMouse as transformationAnchor or resizeAnchor. Autotest included. Task-number: QTBUG-6835 Reviewed-by: bnilsen
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index ffe64aa..3bb40fb 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -1208,6 +1208,11 @@ void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor)
{
Q_D(QGraphicsView);
d->transformationAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->transformationAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
}
/*!
@@ -1235,6 +1240,11 @@ void QGraphicsView::setResizeAnchor(ViewportAnchor anchor)
{
Q_D(QGraphicsView);
d->resizeAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->resizeAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
}
/*!
@@ -2597,9 +2607,12 @@ void QGraphicsView::setupViewport(QWidget *widget)
}
// We are only interested in mouse tracking if items
- // accept hover events or use non-default cursors.
- if (d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
- || !d->scene->d_func()->allItemsUseDefaultCursor)) {
+ // accept hover events or use non-default cursors or if
+ // AnchorUnderMouse is used as transformation or resize anchor.
+ if ((d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor))
+ || d->transformationAnchor == AnchorUnderMouse
+ || d->resizeAnchor == AnchorUnderMouse) {
widget->setMouseTracking(true);
}