In this example, the setStyleSheet() method is used to set the background color of the widget to red using the QColor constructor. Package/library: Qt Example 2 - Drawing a red rectangle on a QPainter object:c++ QPainter painter; painter.setBrush(QBrush(QColor(Qt::red))); painter.drawRect(0, 0, 100, 100); ``` In this example, the setBrush() method is used to set the brush color of the QPainter object to red using QColor constructor, and then the drawRect() method is used to draw a red rectangle on the painter object. Package/library: Qt