I have the following code which should draw a sine function and fill it's internals - everything between this function and zero level. But the brush which I set up does not work. Should any additional function be called? Now I have only sine function and zero level which are drawn without any filling.
void Widget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QPen myPen(Qt::black, 2, Qt::SolidLine);
painter.setPen(myPen);
painter.setBrush(QBrush(QColor(0, 0, 0, 20)));
QPointF* pointArray = new QPointF[251 * 2];
for (int i=0; i < 251; ++i)
{
pointArray[i].setX(i);
pointArray[i].setY(100*qSin(i/10.0));
}
for (int i = 251; i < 251*2; i++)
{
pointArray[i].setX(i - 251);
pointArray[i].setY(0);
}
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
painter.drawPolyline(pointArray, 251*2);
}