Automatically create QPainterPathStroke based on QPen

Based a recent problem where one property of QPen was not properly copied
to QPainterPathStroke, I believe we should add a method to automatically
create a QPainterPathStroke based on all the relevant information in a QPen.

This patch adds a constructor that automatically does so.

Change-Id: Id2849b36426f2e3b06b4b508292063a0917ca61c
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
bb10
Allan Sandfeld Jensen 2013-10-17 17:12:04 +02:00 committed by The Qt Project
parent 72ea1d5992
commit e6c8b86b84
2 changed files with 22 additions and 0 deletions

View File

@ -2550,6 +2550,26 @@ QPainterPathStroker::QPainterPathStroker()
{
}
/*!
Creates a new stroker based on \a pen.
\since 5.3
*/
QPainterPathStroker::QPainterPathStroker(const QPen &pen)
: d_ptr(new QPainterPathStrokerPrivate)
{
setWidth(pen.widthF());
setCapStyle(pen.capStyle());
setJoinStyle(pen.joinStyle());
setMiterLimit(pen.miterLimit());
setDashOffset(pen.dashOffset());
if (pen.style() == Qt::CustomDashLine)
setDashPattern(pen.dashPattern());
else
setDashPattern(pen.style());
}
/*!
Destroys the stroker.
*/

View File

@ -57,6 +57,7 @@ class QPainterPathPrivate;
struct QPainterPathPrivateDeleter;
class QPainterPathData;
class QPainterPathStrokerPrivate;
class QPen;
class QPolygonF;
class QRegion;
class QVectorPath;
@ -243,6 +244,7 @@ class Q_GUI_EXPORT QPainterPathStroker
Q_DECLARE_PRIVATE(QPainterPathStroker)
public:
QPainterPathStroker();
QPainterPathStroker(const QPen &pen);
~QPainterPathStroker();
void setWidth(qreal width);