From 34baceb8da926d5fd88a45e2311e89ea7bc9cd7f Mon Sep 17 00:00:00 2001 From: joshua Date: Sun, 3 Jan 2021 23:30:48 +0100 Subject: [PATCH] Fix bug 175 When use a "dark" Qt theme, some part of element are drawn white/gray instead of black. --- sources/qetgraphicsitem/element.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 748faf265..b0fa035a8 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -213,6 +213,16 @@ void Element::paint( drawHighlight(painter, options); } + //Set default pen and brush to QPainter + //for avoid a strange bug when the Qt theme is a "dark" theme. + //Some part of an element are gray or white instead of black. + //This bug seems append only when the QPainter use drawPicture method. + //See bug 175. https://qelectrotech.org/bugtracker/view.php?id=175 + painter->save(); + QPen pen; + QBrush brush; + painter->setPen(pen); + painter->setBrush(brush); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove if (options && options -> levelOfDetail < 1.0) #else @@ -227,6 +237,8 @@ void Element::paint( painter->drawPicture(0, 0, m_picture); } + painter->restore(); //Restor the QPainter after use drawPicture + //Draw the selection rectangle if ( isSelected() || m_mouse_over ) { drawSelection(painter, options);