From 4af00753fad57989a6ae366cc3dbfc56d88508f4 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 6 Sep 2019 23:24:56 +0200 Subject: Cleanup QtWidgets examples Cleanup QtWidgets examples: - use nullptr (clang-tidy) - use member-initialization - adjust the style - fix includes Change-Id: Ic5448606aacc525ea60b615a69227017aa2b821a Reviewed-by: Paul Wicking --- examples/widgets/painting/gradients/gradients.cpp | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'examples/widgets/painting/gradients/gradients.cpp') diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index a4528ce06f..d62ae93a15 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -102,9 +102,9 @@ uint ShadeWidget::colorAt(int x) generateShade(); QPolygonF pts = m_hoverPoints->points(); - for (int i=1; i < pts.size(); ++i) { - if (pts.at(i-1).x() <= x && pts.at(i).x() >= x) { - QLineF l(pts.at(i-1), pts.at(i)); + for (int i = 1; i < pts.size(); ++i) { + if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) { + QLineF l(pts.at(i - 1), pts.at(i)); l.setLength(l.length() * ((x - l.x1()) / l.dx())); return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))), qRound(qMin(l.y2(), qreal(m_shade.height() - 1)))); @@ -118,9 +118,9 @@ void ShadeWidget::setGradientStops(const QGradientStops &stops) if (m_shade_type == ARGBShade) { m_alpha_gradient = QLinearGradient(0, 0, width(), 0); - for (int i=0; icolorAt(int(x))) >> 16, - (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, - (0x000000ff & m_blue_shade->colorAt(int(x))), - (0xff000000 & m_alpha_shade->colorAt(int(x))) >> 24); + QColor color((0x00ff0000 & m_red_shade->colorAt(x)) >> 16, + (0x0000ff00 & m_green_shade->colorAt(x)) >> 8, + (0x000000ff & m_blue_shade->colorAt(x)), + (0xff000000 & m_alpha_shade->colorAt(x)) >> 24); if (x / w > 1) return; @@ -568,8 +568,8 @@ void GradientRenderer::paint(QPainter *p) g = QConicalGradient(pts.at(0), angle); } - for (int i = 0; i < m_stops.size(); ++i) - g.setColorAt(m_stops.at(i).first, m_stops.at(i).second); + for (const auto &stop : qAsConst(m_stops)) + g.setColorAt(stop.first, stop.second); g.setSpread(m_spread); -- cgit v1.2.3