Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.11, 5.12
-
-
3961cf124af9d811da4bbe72bb28508aef71c7df (qt/qtdeclarative/dev)
Description
QGraphicsView supports for the QPen::cosmetic property that allows the rendering of lines with a fixed size. This is quite useful (if not necessary) when mixing lines with scaling transformations. By default scaling applies also on lines strokes causing lines to be rendered bigger or smaller depending on the scaling factor. However there's not way to invert the scaling for the stroke. The following snippet is NOT a workaround
ShapePath {
...
strokeWidth: 1 / Math.max(yScale, xScale)
}
The previous snippet is suboptimal because the ShapePath could contain multiple PathLine instances and the strokeWidth inverted value could work well for some lines but not for others (based on the line angle). A cosmetic property on the ShapePath instead can apply a different value for each PathLine thus obtaining a better rendering of the line.
The QQuickShapes logic seems to be somehow shared with QGraphicsView implementation. In particular it seems that the class QTriangulatingStroker support the isCosmetic property (see here)