本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView.wheelEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.wheelEvent方法的具体用法?Python QGraphicsView.wheelEvent怎么用?Python QGraphicsView.wheelEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.wheelEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wheelEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import wheelEvent [as 别名]
def wheelEvent(self, event):
'''Handle wheel event.
Argument(s):
event (QWheelEvent): Wheel event
'''
# Only zoom/dezoom if CTRL is pressed
if event.modifiers() == Qt.ControlModifier:
zoomInFactor = 1.25
zoomOutFactor = 1 / zoomInFactor
# Save the scene pos
oldPos = self.mapToScene(event.pos())
# Zoom
if event.angleDelta().y() > 0:
zoomFactor = zoomInFactor
else:
zoomFactor = zoomOutFactor
self.scale(zoomFactor, zoomFactor)
# Get the new position
newPos = self.mapToScene(event.pos())
# Move scene to old position
delta = newPos - oldPos
self.translate(delta.x(), delta.y())
# Move scrollbar
else:
QGraphicsView.wheelEvent(self, event)
示例2: inputGraphicsViewwheelEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import wheelEvent [as 别名]
def inputGraphicsViewwheelEvent(self,event):
scaleFactor = 1.15
if event.delta() > 0:
# Zoom in
self.inputGraphicsView.scale(scaleFactor, scaleFactor)
else:
# Zooming out
self.inputGraphicsView.scale(1.0 / scaleFactor, 1.0 / scaleFactor)
QGraphicsView.wheelEvent(self.inputGraphicsView, event)
示例3: wheelEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import wheelEvent [as 别名]
def wheelEvent(self, event):
'''Zoom In/Out with CTRL + mouse wheel'''
if event.modifiers() == Qt.ControlModifier:
self.scaleView(math.pow(2.0, -event.angleDelta().y() / 240.0))
else:
return QGraphicsView.wheelEvent(self, event)
示例4: wheelEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import wheelEvent [as 别名]
def wheelEvent(self, e):
QGraphicsView.wheelEvent(e)