Skip to content

Commit

Permalink
Trying to make pinch to zoom work nicely on Mac
Browse files Browse the repository at this point in the history
Not sure if I succeeded. I wrote these changes a while ago.
  • Loading branch information
Timmmm committed Dec 5, 2022
1 parent e90b16b commit 6f2bc15
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ZoomableGraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bool ZoomableGraphicsView::event(QEvent* event)

bool ZoomableGraphicsView::gestureEvent(QGestureEvent* event)
{
// Note that this is never actually called for some reason.
if (QGesture* pan = event->gesture(Qt::PanGesture))
panTriggered(static_cast<QPanGesture*>(pan));
else if (QGesture* pinch = event->gesture(Qt::PinchGesture))
Expand All @@ -58,10 +59,9 @@ void ZoomableGraphicsView::pinchTriggered(QPinchGesture* gesture)

void ZoomableGraphicsView::wheelEvent(QWheelEvent* event)
{
// For synthesized mouse events, i.e. ones not from a real mouse wheel
// For non-mouse events (e.g. pinch-zoom on a touchpad generates scroll events)
// use the default implementation, which does nothing (we use pinch to zoom instead).
if (event->source() != Qt::MouseEventNotSynthesized)
return QGraphicsView::wheelEvent(event);
qDebug() << "wheelEvent(): " << event->device()->type();

double scaleBy = 1.0;

Expand Down

0 comments on commit 6f2bc15

Please sign in to comment.