PDA

View Full Version : Filling an ellipse with a QRadialGradient brush



Caius Aérobus
29th October 2008, 16:36
Hello,
I would like to draw an ellipse and fill it with a QRadialGradient brush. So I have 2 questions:

what is the difference between focal and center points in a QRadialGradient?
here is my code, which draws a classical - empty - ellipse, what should I add to fill it with the selected brush?
QRadialGradient rg(this->fire_point, this->fire_size);
rg.setColorAt(0, Qt::red);
rg.setColorAt(1, Qt::white);
pen.setBrush(QBrush(rg));
painter.setPen(pen);
painter.drawEllipse(this->fire_point.x(), this->fire_point.y(), this->fire_size*2, this->fire_size*2);

hwerglmir
30th October 2008, 07:16
Question 2:
You have to set the brush of the painter, not of the pen.
The pen draws only the border.


QRadialGradient rg(this->fire_point, this->fire_size);
rg.setColorAt(0, Qt::red);
rg.setColorAt(1, Qt::white);
painter.setBrush(QBrush(rg));
painter.drawEllipse(this->fire_point.x(), this->fire_point.y(), this->fire_size*2, this->fire_size*2);