QBrush brush; brush.setColor(QColor(255, 0, 0)); // Set color to red // or using shorthand version QBrush brush(QColor(255, 0, 0)); // Set color to red
QBrush brush; brush.setColor(QColor("#ff0000")); // Set color to red // or using shorthand version QBrush brush(QColor("#ff0000")); // Set color to redThis example sets the color of the QBrush object to red using a hexadecimal code (#ff0000). The first two characters represent the amount of red, followed by the amount of green, followed by the amount of blue. Both examples use the Qt package library to create the QBrush object and set the color using its setColor method.