gradient.setColorAt(0,Qt::red);
gradient.setColorAt(0.5,Qt::green);
gradient.setColorAt(0,Qt::blue);
painter.setBrush(gradient);
painter.drawRect(0,0,100,100);
window.show();
return app.exec();
QApplication app(argc,argv);
QWidget window;
QPainter painter;
QLinearGradient gradient(0,0,100,100);
gradient.setColorAt(0,Qt::red);
gradient.setColorAt(0.5,Qt::green);
gradient.setColorAt(0,Qt::blue);
painter.setBrush(gradient);
painter.drawRect(0,0,100,100);
window.show();
return app.exec();
To copy to clipboard, switch view to plain text mode
Bookmarks