From 4ec304fe91876297ea387be4ec03afb49b6511c6 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 20 Dec 2022 15:49:09 +0100 Subject: [PATCH] QGradient replaces when adding a stop at the same position, instaed of appending it - like how it is with CSS or Qsk. As a workaround we increase the positon by a small epsilon. --- src/common/QskGradientStop.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/common/QskGradientStop.cpp b/src/common/QskGradientStop.cpp index 1d916881..9874c683 100644 --- a/src/common/QskGradientStop.cpp +++ b/src/common/QskGradientStop.cpp @@ -387,12 +387,25 @@ QskGradientStops qskBuildGradientStops( const QVector< QColor >& colors, bool di QGradientStops qskToQGradientStops( const QskGradientStops& stops ) { - QGradientStops qstops; - qstops.reserve( stops.count() ); + QGradientStops qStops; + qStops.reserve( stops.count() ); for ( const auto& stop : stops ) - qstops += { stop.position(), stop.color() }; + { + QPair qStop = { stop.position(), stop.color() }; - return qstops; + if ( !qStops.isEmpty() && qStops.last().first == qStop.first ) + { + /* + QGradient removes stops at the same position. So we have to insert + an invisible dummy offset + */ + qStop.first += 0.00001; + } + + qStops += qStop; + } + + return qStops; }