Skip to content

Commit ce2e516

Browse files
author
Vincent Drevelle
committed
Zoom in and out with keys Q and W or + and -.
1 parent bf34a0f commit ce2e516

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

viewer/figure2d.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ void Figure2D::wheelEvent(QWheelEvent *event)
7575
// fitInView(sceneRect());
7676
}
7777

78+
void Figure2D::keyPressEvent(QKeyEvent *event)
79+
{
80+
switch(event->key())
81+
{
82+
case Qt::Key_Plus:
83+
case Qt::Key_Q:
84+
this->scale(1.25,1.25);
85+
break;
86+
case Qt::Key_Minus:
87+
case Qt::Key_W:
88+
this->scale(0.8,0.8);
89+
break;
90+
default:
91+
QGraphicsView::keyPressEvent(event);
92+
}
93+
}
94+
7895
void Figure2D::exportGraphics(QString fileName)
7996
{
8097
// Open file save dialog if no filename given

viewer/figure2d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Figure2D : public QGraphicsView
1919
protected:
2020
void drawForeground(QPainter *painter, const QRectF &rect);
2121
void wheelEvent(QWheelEvent *event);
22+
void keyPressEvent(QKeyEvent *event);
2223

2324
signals:
2425

0 commit comments

Comments
 (0)