#includeint main() { QColor color(255, 0, 0); // red color color.setGreen(128); // set green component to 128 // color is now yellowish-red return 0; }
#includeIn this example, we create a QColor object representing a pure green color using a hexadecimal code. We then use the setGreen() function to set the green component to 0, resulting in pure red color. The QColor class is part of the Qt GUI library.int main() { QColor color("#00FF00"); // green color color.setGreen(0); // set green component to 0 (no green) // color is now pure red return 0; }