Qt C++

#include 
int main(int argv, char **args)
{
    QApplication app(argv, args);
    QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
    linearGrad.setColorAt(0, Qt::black);
    linearGrad.setColorAt(1, Qt::white);
    QBrush brush(linearGrad);
        QPainter painter;
        QPen pen(Qt::red, 2);                 // red solid line, 2 pixels wide
        painter.setPen(pen);              // set the red, wide pen
        painter.drawRect(40,30, 200,100); // draw a rectangle
        painter.setPen(Qt::blue);             // set blue pen, 0 pixel width
        painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
        painter.end();                    // painting done
    QWidget widget;
    QPalette palette;
    palette.setBrush(widget.backgroundRole(), brush);
    widget.setPalette(palette);
    widget.show();
    return app.exec();
}