QColor color(255, 0, 0); //create a red color color.setRedF(0.5); //set the red component to 0.5
QColor color(0, 255, 255); //create a cyan color color.setRedF(1); //set the red component to 1 (maximum value)In this example, we create a QColor object that is initially cyan. We then use the setRedF function to set the red component to 1, which changes the color to completely red. The package library for this function is the Qt library.