How do you scale a pen so that the pen width appears constant when the view is scaled
Here's my QGraphicsView code:
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)
viewScale() of scene() in turn calls viewScale of SnapGridGraphicsItem:
Code:
def viewScale(self, scale):
#self.pen.setWidth(1.0 / scale)
self.
pen = QPen(self.
color,
1.0 / scale
)
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...
Re: How do you scale a pen so that the pen width appears constant when the view is sc