diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2022-05-31 09:50:45 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2022-05-31 22:30:22 +0200 |
commit | b539dc118efb0a37826ac101b610f21483bf2498 (patch) | |
tree | 470584b346b9aa3b6eb5ced5d2aff3ca88378fb4 /src/widgets/styles | |
parent | 567ffafe7fed4536359e8a6b925aaf4379d67b67 (diff) |
Avoid menu separators disappearing under fractional dpr scaling
An aliased line painted directly on top of the top edge of the clip
rect will work fine when there is no scaling, since the coordinates
will snap downwards. When a fractional scaling is applied however, the
main part of the line width will sometimes fall outside the clip rect,
and so the coordinates will snap it outside, and hence it will not be
painted.
Fix by shifting the y coordinate by .5, to place the center coordinate
of the line to the center of the intended pixel.
Fixes: QTBUG-88934
Task-number: QTBUG-96223
Pick-to: 6.3 6.2
Change-Id: I3ab042bc964eac6ce359d40428c4d79cde9cb78c
Reviewed-by: Nodir Temirkhodjaev <nodir.temir@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index f923c4562e..9ee6a30810 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1519,8 +1519,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->setPen(shadow.lighter(106)); const bool reverse = menuItem->direction == Qt::RightToLeft; - painter->drawLine(menuItem->rect.left() + margin + (reverse ? 0 : w), menuItem->rect.center().y(), - menuItem->rect.right() - margin - (reverse ? w : 0), menuItem->rect.center().y()); + qreal y = menuItem->rect.center().y() + 0.5f; + painter->drawLine(QPointF(menuItem->rect.left() + margin + (reverse ? 0 : w), y), + QPointF(menuItem->rect.right() - margin - (reverse ? w : 0), y)); painter->restore(); break; } |