From 97b304ea746d3ad380fa1ac31409cadc4dbb139b Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 6 May 2020 16:51:02 +0530 Subject: scroll wheel init --- src/main/python/utils/graphics.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/main/python/utils/graphics.py') diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py index fc80254..9e1f690 100644 --- a/src/main/python/utils/graphics.py +++ b/src/main/python/utils/graphics.py @@ -1 +1,15 @@ -pass \ No newline at end of file +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QGraphicsView +class customView(QGraphicsView): + + def __init__(self, scene, parent=None): + super(customView, self).__init__(scene, parent) + self.zoom = 1 + + def wheelEvent(self, QWheelEvent): + if Qt.ControlModifier: + self.zoom += QWheelEvent.angleDelta().y()/2880 + self.scale(self.zoom, self.zoom) + QWheelEvent.accept() + else: + return super().wheelEvent(self, QWheelEvent) \ No newline at end of file -- cgit