Here's my QGraphicsView code:
def wheelEvent(self, event):
if QApplication.
keyboardModifiers() & (Qt.
ControlModifier | Qt.
ShiftModifier): self.setTransformationAnchor(self.AnchorUnderMouse)
#Scale the view / do the zoom
scaleFactor = 1.08
if event.angleDelta().y() > 0:
#Zoom in
self.scale(scaleFactor, scaleFactor)
else:
self.scale(1.0/scaleFactor, 1.0/scaleFactor)
#Assumes scaleX = scaleY
def scale(self, scaleX, scaleY):
self.scene().viewScale(scaleX)
def wheelEvent(self, event):
if QApplication.keyboardModifiers() & (Qt.ControlModifier | Qt.ShiftModifier):
self.setTransformationAnchor(self.AnchorUnderMouse)
#Scale the view / do the zoom
scaleFactor = 1.08
if event.angleDelta().y() > 0:
#Zoom in
self.scale(scaleFactor, scaleFactor)
else:
self.scale(1.0/scaleFactor, 1.0/scaleFactor)
#Assumes scaleX = scaleY
def scale(self, scaleX, scaleY):
self.scene().viewScale(scaleX)
QGraphicsView.scale(self, scaleX, scaleY)
To copy to clipboard, switch view to plain text mode
viewScale() of scene() in turn calls viewScale of SnapGridGraphicsItem:
def viewScale(self, scale):
#self.pen.setWidth(1.0 / scale)
self.
pen = QPen(self.
color,
1.0 / scale
)
def viewScale(self, scale):
#self.pen.setWidth(1.0 / scale)
self.pen = QPen(self.color, 1.0 / scale)
To copy to clipboard, switch view to plain text mode
I've also tried multiplying 1.0 / scale x pen.width() and the same result happens: nothing - lines are still scaled with zoom action. Please help! :|
I also already have ItemIgnoresGeometricTransformations enabled for SnapGridGraphicsItem...
Bookmarks