Avoid QRubberBand leaving artefacts in QListView

On hidpi screens, the painted edges of the rubberband can extend
beyond the selection rect because of scaling. Extend the area to be
updated by 2x frame width, when the rubberband changes.

Fixes: QTBUG-113432
Pick-to: 6.7 6.6 6.5
Change-Id: Ie7aec1fefdc3fbf71c63952b693f462697adf849
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
Eirik Aavitsland 2023-09-11 16:59:36 +02:00 committed by Axel Spoerl
parent cb5aac06cf
commit a5a6b657a7
1 changed files with 7 additions and 2 deletions

View File

@ -755,7 +755,10 @@ void QListView::mouseMoveEvent(QMouseEvent *e)
&& d->selectionMode != NoSelection) {
QRect rect(d->pressedPosition, e->position().toPoint() + QPoint(horizontalOffset(), verticalOffset()));
rect = rect.normalized();
d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));
const int margin = 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
const QRect viewPortRect = rect.united(d->elasticBand)
.adjusted(-margin, -margin, margin, margin);
d->viewport->update(d->mapToViewport(viewPortRect));
d->elasticBand = rect;
}
}
@ -769,7 +772,9 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
QAbstractItemView::mouseReleaseEvent(e);
// #### move this implementation into a dynamic class
if (d->showElasticBand && d->elasticBand.isValid()) {
d->viewport->update(d->mapToViewport(d->elasticBand));
const int margin = 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
const QRect viewPortRect = d->elasticBand.adjusted(-margin, -margin, margin, margin);
d->viewport->update(d->mapToViewport(viewPortRect));
d->elasticBand = QRect();
}
}