QBrush brush(Qt::red);
QGradient gradient(QGradient::LinearGradient, QPoint(0, 0), QPoint(100, 100)); gradient.setColorAt(0.0, Qt::white); gradient.setColorAt(0.5, Qt::gray); gradient.setColorAt(1.0, Qt::black); QBrush brush(gradient);
QPixmap pixmap("path/to/texture.png"); QBrush brush(pixmap);This code loads a texture from a file and uses it to create a QBrush object with a pattern fill. In conclusion, QBrush is a QtGui class that can be used to represent fill properties of a QPainter's drawing brush, and it is used for setting solid colors, creating gradients and patterns.