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>
This commit is contained in:
parent
180c662b07
commit
0ca3f1732a
@ -3230,8 +3230,8 @@ static StaticPolygonF<3> calcArrow(const QStyleOptionSlider *dial, qreal &a)
|
|||||||
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
|
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
|
||||||
/ (dial->maximum - dial->minimum)) / 6;
|
/ (dial->maximum - dial->minimum)) / 6;
|
||||||
|
|
||||||
int xc = width / 2;
|
int xc = width / 2 + dial->rect.left();
|
||||||
int yc = height / 2;
|
int yc = height / 2 + dial->rect.top();
|
||||||
|
|
||||||
int len = r - QStyleHelper::calcBigLineSize(r) - 5;
|
int len = r - QStyleHelper::calcBigLineSize(r) - 5;
|
||||||
if (len < 5)
|
if (len < 5)
|
||||||
|
@ -181,7 +181,7 @@ static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
|
|||||||
qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
|
qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
|
||||||
qreal back = offset * len;
|
qreal back = offset * len;
|
||||||
QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
|
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)
|
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);
|
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
|
// 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);
|
p->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
const qreal d_ = r / 6;
|
const qreal d_ = r / 6;
|
||||||
const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
|
const qreal dx = d_ + (width - 2 * r) / 2 + 1;
|
||||||
const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
|
const qreal dy = d_ + (height - 2 * r) / 2 + 1;
|
||||||
|
|
||||||
QRectF br = QRectF(dx + 0.5, dy + 0.5,
|
QRectF br = QRectF(dx + 0.5, dy + 0.5,
|
||||||
int(r * 2 - 2 * d_ - 2),
|
int(r * 2 - 2 * d_ - 2),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user