Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2.0
-
None
Description
Hello,
The following 2 code snippets behave quite differently:
a)
QPainterPathStroker stroker; stroker.setWidth(buffWidth); stroker.setCurveThreshold(0.01);
b)
QPainterPathStroker stroker; stroker.setCurveThreshold(0.01); stroker.setWidth(buffWidth);
As you might notice the only difference is the ordering of setWidth and setCurveThreshold.
in b) setCurveThreshold has no effect, as the internal data is overwriten when calling setWidth:
void QPainterPathStroker::setWidth(qreal width) { Q_D(QPainterPathStroker); if (width <= 0) width = 1; d->stroker.setStrokeWidth(qt_real_to_fixed(width)); } ... class Q_GUI_EXPORT QStroker : public QStrokerOps ... void setStrokeWidth(qfixed width) { m_strokeWidth = width; m_curveThreshold = qt_real_to_fixed(qBound(0.00025, 1.0 / qt_fixed_to_real(width), 0.25)); }
QDashStroker seems not to have this problem.
This actually is a minor flaw, but it took me literally days to find this solution (by chance) as i took huge efforts to work around accuracy problems using QPainterPathStroker. They all vanished by just reordering the 2 Lines.
I think that setWidth should not overwrite a explicit setting made by setCurveThreshold.
QPainterPathStroker is a great tool by the way. The only one o could find that does so by using curves and not polygons.