Modify the internal rectangle drawing of CE_RubberBand

adjusted(1, 1, -2, -2) makes the rectangle smaller, but when
rect.x1-rect.x2 = 0. Then x1 + 1, x2-2 leads to x1> x2. This will
make the rectangle flip in advance. So there is a difference
between the updated area and the drawn area.

Add a judgment, when the rectangle we get is large enough, draw the inner rectangle.

Fixes: QTBUG-95716
Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io>
Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Pick-to: 6.2
Change-Id: I0d081a4ad7aee4a563acb988c0ef19a646bf1eea
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tang Haixiang 2021-08-11 13:52:11 +08:00
parent d8f815db7f
commit 77bdce8496

View File

@ -1088,10 +1088,13 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
painter->translate(0.5, 0.5);
painter->setBrush(dimHighlight);
painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 1, 1);
QColor innerLine = Qt::white;
innerLine.setAlpha(40);
painter->setPen(innerLine);
painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1);
//when the rectangle we get is large enough, draw the inner rectangle.
if (option->rect.width() > 2 && option->rect.height() > 2) {
QColor innerLine = Qt::white;
innerLine.setAlpha(40);
painter->setPen(innerLine);
painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1);
}
painter->restore();
}
break;