From e6c8b86b84172816ef316f8fdcb8a86702208150 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Oct 2013 17:12:04 +0200 Subject: 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 --- src/gui/painting/qpainterpath.cpp | 20 ++++++++++++++++++++ src/gui/painting/qpainterpath.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 156e411154..b4c42f7060 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -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. */ diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index e22c1729f3..c922867eb9 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -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); -- cgit v1.2.3