diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index f5dd5396505..5498cdea651 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -189,20 +189,20 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q case PE_FrameFocusRect: if (const QStyleOptionFocusRect *fropt = qstyleoption_cast(opt)) { QColor bg = fropt->backgroundColor; - QPen oldPen = p->pen(); + QColor color; if (bg.isValid()) { int h, s, v; bg.getHsv(&h, &s, &v); if (v >= 128) - p->setPen(Qt::black); + color = Qt::black; else - p->setPen(Qt::white); + color = Qt::white; } else { - p->setPen(opt->palette.windowText().color()); + color = opt->palette.windowText().color(); } - QRect focusRect = opt->rect.adjusted(1, 1, -1, -1); - p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive - p->setPen(oldPen); + const QRect focusRect = opt->rect.adjusted(1, 1, -1, -1); + const QBrush fill(bg); + qDrawPlainRect(p, focusRect, color, 1, bg.isValid() ? &fill : nullptr); } break; case PE_IndicatorMenuCheckMark: {