I want to draw patterns (preferable as QPixmap) along a QGraphicsPathItem inside my QGraphicsView. This should work similar to filling a QBrush with a texture by using QBrush.setTexture("example.png")
. Is there a way to do this on a QPen? I couldn't find anything related to this in the PyQt documentation.
The texture should be placed similar to this example picture
It doesn't matter if the texture keeps it's own width or is scaled to QPen's width.
Is there some form of workaround to implement this? I was thinking about using QTransform in a way to transform QPixmap to the shape of the desired QGraphicsPathItem.
I still haven't found a statisfying solution. But for people that dont require the pattern to be aligned along the path, you can use this piece of code for your QPen:
It fills your QGraphicsPathItem like this
I hope this is helpful for others.