summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-12-02 17:04:47 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-11 13:37:57 +0100
commit9cf56b3e09114f65f23bb4a8062d632df94b8a04 (patch)
treeee80ded6f062a1339a180d2e7d108f3e199b160c /tests
parentd0a6d6a21516ff8b300ad1181625005b60982f75 (diff)
QGraphicsView - fix rubberband to expand on wheel event
In SHA 51914375b615ddcac711171ac31779fea01b4323 the rubberband selection was fixed, so it followed the scene-point on mousemove. However wheelEvent could move the view - but avoid update of the rubberband (that would not be updated until next mouse-move). This patch fixes that (and generally improves rubberband behavior) since QGraphicsViewPrivate::mouseMoveEventHandler is called by replayLastMouseEvent, which is called from various places, where we need to update the rubberband (e.g scrollContentsBy). Change-Id: I1b78c27edaaecea797a2319086d7a11d437d2bd3 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
index d8c2de6398..186203e7d8 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
@@ -69,11 +69,17 @@ public:
protected:
void mouseMoveEvent(QMouseEvent *event)
{
+ QGraphicsView::mouseMoveEvent(event);
+
int rightmostInView = viewport()->mapToGlobal(viewport()->geometry().topRight()).x();
int xglobal = event->globalX();
if (xglobal > rightmostInView)
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 10);
- QGraphicsView::mouseMoveEvent(event);
+
+ int bottomPos = viewport()->mapToGlobal(viewport()->geometry().bottomRight()).y();
+ int yglobal = event->globalY();
+ if (yglobal > bottomPos)
+ verticalScrollBar()->setValue(verticalScrollBar()->value() + 10);
}
};
@@ -82,17 +88,18 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
MyGraphicsView v;
- QGraphicsScene s(0.0, 0.0, 10000.0, 100.0);
+ QGraphicsScene s(0.0, 0.0, 5000.0, 5000.0);
v.setScene(&s);
v.setInteractive(true);
v.setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect);
s.addRect( (qreal) 0.0, 0.0, 1000.0, 50.0, QPen(),QBrush(QColor(0,0,255)));
- for (int u = 0; u < 100; ++u) {
- MyGraphicsItem *item = new MyGraphicsItem();
- item->setRect(QRectF(u * 100, 50.0, 50.0, 20.0));
- s.addItem(item);
- }
+ for (int u = 0; u < 100; ++u)
+ for (int v = 0; v < 100; ++v) {
+ MyGraphicsItem *item = new MyGraphicsItem();
+ item->setRect(QRectF(v * 80.0, u * 80.0, 50.0, 20.0));
+ s.addItem(item);
+ }
v.show();
app.exec();
return 0;