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);