From 803bebe62face37310fd8d8b97ca7faa1d4284a8 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 9 Oct 2009 12:10:42 +0200 Subject: Made QPen::setDashOffset() work with non-custom dashed lines. Task-number: QTBUG-2738 Reviewed-by: Trond --- src/gui/painting/qpen.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index a050cb2..41efc80 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -411,6 +411,8 @@ Qt::PenStyle QPen::style() const pattern using the setDashPattern() function which implicitly converts the style of the pen to Qt::CustomDashLine. + \note This function resets the dash offset to zero. + \sa style(), {QPen#Pen Style}{Pen Style} */ @@ -420,7 +422,9 @@ void QPen::setStyle(Qt::PenStyle s) return; detach(); d->style = s; - static_cast(d)->dashPattern.clear(); + QPenData *dd = static_cast(d); + dd->dashPattern.clear(); + dd->dashOffset = 0; } /*! @@ -538,8 +542,12 @@ void QPen::setDashOffset(qreal offset) if (qFuzzyCompare(offset, static_cast(d)->dashOffset)) return; detach(); - static_cast(d)->dashOffset = offset; - d->style = Qt::CustomDashLine; + QPenData *dd = static_cast(d); + dd->dashOffset = offset; + if (d->style != Qt::CustomDashLine) { + dd->dashPattern = dashPattern(); + d->style = Qt::CustomDashLine; + } } /*! -- cgit v0.12