Annihilator
6th July 2013, 19:15
I'm trying to draw a thick arc using QPainterPath
QPainterPath* path = new QPainterPath();
path->arcMoveTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45);
// drawing the first (outer) arc from -45 to 225 degrees (counter-clockwise)
path->arcTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45, 270);
path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
// drawing the second (inner) arc from 225 to -45 degrees (clockwise)
path->arcTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225, -270);
path->lineTo(gradientTopRight); // line up to the first arc
path->closeSubpath();
QLinearGradient gradient(innerRect.topLeft(), innerRect.topRight());
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::red);
painter.fillPath(*path, QBrush(gradient));
But what I actually get is here
http://screencast.com/t/Li1dtXc3
Can anybody help please?
Added after 42 minutes:
Solved
instead of
path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
wrote
entirePath->lineTo(gradientBottomLeft);
QPainterPath* path = new QPainterPath();
path->arcMoveTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45);
// drawing the first (outer) arc from -45 to 225 degrees (counter-clockwise)
path->arcTo(-innerWidth/2.0, -innerWidth/2.0, innerWidth, innerWidth, -45, 270);
path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
// drawing the second (inner) arc from 225 to -45 degrees (clockwise)
path->arcTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225, -270);
path->lineTo(gradientTopRight); // line up to the first arc
path->closeSubpath();
QLinearGradient gradient(innerRect.topLeft(), innerRect.topRight());
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::red);
painter.fillPath(*path, QBrush(gradient));
But what I actually get is here
http://screencast.com/t/Li1dtXc3
Can anybody help please?
Added after 42 minutes:
Solved
instead of
path->arcMoveTo(-innerWidth/2.0 + gradientPartThickness, -innerWidth/2.0 + gradientPartThickness, innerWidth - gradientPartThickness*2, innerWidth - gradientPartThickness*2, 225);
wrote
entirePath->lineTo(gradientBottomLeft);