Fix compilation with -qreal float

Task-number: QTBUG-118877
Pick-to: 6.8
Change-Id: I249db4583517d153c63f35e379c7a33c47aeec27
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
This commit is contained in:
Tim Blechmann 2024-08-13 13:10:43 +08:00
parent b482c195e7
commit 094a25ddb4
8 changed files with 19 additions and 14 deletions

View File

@ -29,8 +29,10 @@ QVariant QGraphPointAnimation::interpolated(const QVariant &start,
auto startPoint = qvariant_cast<QPointF>(start);
auto endPoint = qvariant_cast<QPointF>(end);
auto interpolatedPoint = QPointF{startPoint.x() * (1.0 - progress) + endPoint.x() * progress,
startPoint.y() * (1.0 - progress) + endPoint.y() * progress};
auto interpolatedPoint = QPointF{
qreal(startPoint.x() * (1.0 - progress) + endPoint.x() * progress),
qreal(startPoint.y() * (1.0 - progress) + endPoint.y() * progress),
};
return QVariant::fromValue(interpolatedPoint);
}
@ -76,8 +78,10 @@ void QGraphPointAnimation::animate()
} else {
auto lastPoint = m_pointsState[m_newPointIndex - 1];
auto nextPoint = m_pointsState[m_newPointIndex + 1];
auto midpoint = QPointF{(nextPoint.x() + lastPoint.x()) * 0.5,
(nextPoint.y() + lastPoint.y()) * 0.5};
auto midpoint = QPointF{
qreal((nextPoint.x() + lastPoint.x()) * 0.5),
qreal((nextPoint.y() + lastPoint.y()) * 0.5),
};
auto endv = QVariant::fromValue(midpoint);
setAnimatingValue(startv, endv);

View File

@ -30,8 +30,9 @@ QVariant QSplineControlAnimation::interpolated(const QVariant &start,
auto interpolateList = QList<QPointF>();
for (int i = 0; i < endList.size(); ++i) {
interpolateList.push_back({startList[i].x() * (1.0 - progress) + endList[i].x() * progress,
startList[i].y() * (1.0 - progress) + endList[i].y() * progress});
interpolateList.push_back(
{ qreal(startList[i].x() * (1.0 - progress) + endList[i].x() * progress),
qreal(startList[i].y() * (1.0 - progress) + endList[i].y() * progress) });
}
return QVariant::fromValue(interpolateList);

View File

@ -1129,7 +1129,7 @@ qsizetype QBarSeriesPrivate::categoryCount() const
void QBarSeriesPrivate::setBarWidth(qreal width)
{
Q_Q(QBarSeries);
width = std::clamp(width, 0.0, 1.0);
width = std::clamp<qreal>(width, 0.0, 1.0);
if (!qFuzzyCompare(width, m_barWidth)) {
m_barWidth = width;
q->update();

View File

@ -369,7 +369,7 @@ qreal QAbstractSeries::valuesMultiplier() const
void QAbstractSeries::setValuesMultiplier(qreal valuesMultiplier)
{
Q_D(QAbstractSeries);
valuesMultiplier = std::clamp(valuesMultiplier, 0.0, 1.0);
valuesMultiplier = std::clamp<qreal>(valuesMultiplier, 0.0, 1.0);
if (valuesMultiplier != d->m_valuesMultiplier) {
d->m_valuesMultiplier = valuesMultiplier;
update();

View File

@ -176,7 +176,7 @@ void AreaRenderer::handlePolish(QAreaSeries *series)
}
qreal borderWidth = series->borderWidth();
if (qFuzzyCompare(borderWidth, -1.0))
if (qFuzzyCompare(borderWidth, qreal(-1.0)))
borderWidth = theme->borderWidth();
group->shapePath->setStrokeWidth(borderWidth);

View File

@ -260,7 +260,7 @@ void AxisRenderer::updateAxis()
// Todo: make constant for all axis, or clamp in class? (QTBUG-124736)
const double MAX_DIVS = 100.0;
double interval = std::clamp(vaxis->tickInterval(), 0.0, MAX_DIVS);
double interval = std::clamp<double>(vaxis->tickInterval(), 0.0, MAX_DIVS);
m_axisVerticalMaxValue = vaxis->max().toMSecsSinceEpoch();
m_axisVerticalMinValue = vaxis->min().toMSecsSinceEpoch();
m_axisVerticalValueRange = std::abs(m_axisVerticalMaxValue - m_axisVerticalMinValue);
@ -293,7 +293,7 @@ void AxisRenderer::updateAxis()
if (auto haxis = qobject_cast<QDateTimeAxis *>(m_axisHorizontal)) {
const double MAX_DIVS = 100.0;
double interval = std::clamp(haxis->tickInterval(), 0.0, MAX_DIVS);
double interval = std::clamp<double>(haxis->tickInterval(), 0.0, MAX_DIVS);
m_axisHorizontalMaxValue = haxis->max().toMSecsSinceEpoch();
m_axisHorizontalMinValue = haxis->min().toMSecsSinceEpoch();
m_axisHorizontalValueRange = std::abs(m_axisHorizontalMaxValue - m_axisHorizontalMinValue);

View File

@ -76,7 +76,7 @@ qreal BarsRenderer::getSetBorderWidth(QBarSeries *series, QBarSet *set)
Q_UNUSED(series);
auto theme = m_graph->theme();
qreal borderWidth = set->borderWidth();
if (qFuzzyCompare(borderWidth, -1.0))
if (qFuzzyCompare(borderWidth, qreal(-1.0)))
borderWidth = theme->borderWidth();
return borderWidth;
}

View File

@ -303,8 +303,8 @@ void QLogValue3DAxisFormatterPrivate::recalculate()
qreal minDiff = qCeil(logMin) - logMin;
qreal maxDiff = logMax - qFloor(logMax);
m_evenMinSegment = qFuzzyCompare(0.0, minDiff);
m_evenMaxSegment = qFuzzyCompare(0.0, maxDiff);
m_evenMinSegment = qFuzzyCompare(qreal(0.0), minDiff);
m_evenMaxSegment = qFuzzyCompare(qreal(0.0), maxDiff);
segmentCount = qRound(logRangeNormalizer - minDiff - maxDiff);