summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstylehelper.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-12-22 15:43:13 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2021-01-29 07:26:56 +0100
commit0ca3f1732ae9aa8e138142890a35c0b183c55ffd (patch)
tree0eec13238c7138c484fcebd8a3070b6904cc0c80 /src/widgets/styles/qstylehelper.cpp
parent180c662b0790c6eceffdcb4661681d7df1541a2d (diff)
QDial: fix painting QDial when the rect has an offset
When the QDial should be painted with an offset, the dial was not draw correct. Fixes: QTBUG-89574 Change-Id: I646c3d42fba34e8c603a8f81f363ed827f04d5de Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles/qstylehelper.cpp')
-rw-r--r--src/widgets/styles/qstylehelper.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index d8e0495b37..377df7705b 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -181,7 +181,7 @@ static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
qreal back = offset * len;
QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
- return pos;
+ return pos + dial->rect.topLeft();
}
qreal angle(const QPointF &p1, const QPointF &p2)
@@ -254,7 +254,7 @@ QPolygonF calcLines(const QStyleOptionSlider *dial)
poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
}
}
- return poly;
+ return poly.translated(dial->rect.topLeft());
}
// This will draw a nice and shiny QDial for us. We don't want
@@ -291,8 +291,8 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
p->setRenderHint(QPainter::Antialiasing);
const qreal d_ = r / 6;
- const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
- const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
+ const qreal dx = d_ + (width - 2 * r) / 2 + 1;
+ const qreal dy = d_ + (height - 2 * r) / 2 + 1;
QRectF br = QRectF(dx + 0.5, dy + 0.5,
int(r * 2 - 2 * d_ - 2),